Spaces:
Runtime error
Runtime error
init
Browse files- Makefile +13 -0
- README.md +30 -6
- app.py +348 -0
- pyproject.toml +13 -0
- requirements.txt +15 -0
- scripts/create_request_file.py +107 -0
- src/.DS_Store +0 -0
- src/display/.DS_Store +0 -0
- src/display/about.py +198 -0
- src/display/css_html_js.py +111 -0
- src/display/formatting.py +36 -0
- src/display/pictures/occiglot.medium.png +0 -0
- src/display/utils.py +139 -0
- src/envs.py +19 -0
- src/leaderboard/read_evals.py +204 -0
- src/populate.py +55 -0
- src/submission/check_validity.py +103 -0
- src/submission/submit.py +118 -0
Makefile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.PHONY: style format
|
2 |
+
|
3 |
+
|
4 |
+
style:
|
5 |
+
python -m black --line-length 119 .
|
6 |
+
python -m isort .
|
7 |
+
ruff check --fix .
|
8 |
+
|
9 |
+
|
10 |
+
quality:
|
11 |
+
python -m black --check --line-length 119 .
|
12 |
+
python -m isort --check-only .
|
13 |
+
ruff check .
|
README.md
CHANGED
@@ -1,12 +1,36 @@
|
|
1 |
---
|
2 |
-
title: Euro Leaderboard
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: Occiglot Euro LLM Leaderboard
|
3 |
+
emoji: 🥇
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.4.0
|
8 |
app_file: app.py
|
9 |
+
pinned: true
|
10 |
+
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
|
15 |
+
Most of the variables to change for a default leaderboard are in env (replace the path for your leaderboard) and src/display/about.
|
16 |
+
|
17 |
+
Results files should have the following format:
|
18 |
+
```
|
19 |
+
{
|
20 |
+
"config": {
|
21 |
+
"model_dtype": "torch.float16", # or torch.bfloat16 or 8bit or 4bit
|
22 |
+
"model_name": "path of the model on the hub: org/model",
|
23 |
+
"model_sha": "revision on the hub",
|
24 |
+
},
|
25 |
+
"results": {
|
26 |
+
"task_name": {
|
27 |
+
"metric_name": score,
|
28 |
+
},
|
29 |
+
"task_name2": {
|
30 |
+
"metric_name": score,
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
```
|
35 |
+
|
36 |
+
Request files are created automatically by this tool.
|
app.py
ADDED
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import os
|
4 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
+
from huggingface_hub import snapshot_download
|
6 |
+
|
7 |
+
from src.display.about import (
|
8 |
+
CITATION_BUTTON_LABEL,
|
9 |
+
CITATION_BUTTON_TEXT,
|
10 |
+
EVALUATION_QUEUE_TEXT,
|
11 |
+
INTRODUCTION_TEXT,
|
12 |
+
LLM_BENCHMARKS_TEXT,
|
13 |
+
TITLE,
|
14 |
+
OCCIGLOT_SUPPORT,
|
15 |
+
)
|
16 |
+
from src.display.css_html_js import custom_css
|
17 |
+
from src.display.utils import (
|
18 |
+
BENCHMARK_COLS,
|
19 |
+
COLS,
|
20 |
+
EVAL_COLS,
|
21 |
+
EVAL_TYPES,
|
22 |
+
NUMERIC_INTERVALS,
|
23 |
+
TYPES,
|
24 |
+
AutoEvalColumn,
|
25 |
+
ModelType,
|
26 |
+
fields,
|
27 |
+
WeightType,
|
28 |
+
Precision
|
29 |
+
)
|
30 |
+
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, TOKEN, QUEUE_REPO, REPO_ID, RESULTS_REPO
|
31 |
+
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
32 |
+
from src.submission.submit import add_new_eval
|
33 |
+
|
34 |
+
|
35 |
+
def restart_space():
|
36 |
+
API.restart_space(repo_id=REPO_ID, token=TOKEN)
|
37 |
+
|
38 |
+
try:
|
39 |
+
snapshot_download(
|
40 |
+
repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, token=TOKEN, repo_type="dataset", tqdm_class=None, etag_timeout=30
|
41 |
+
)
|
42 |
+
except Exception:
|
43 |
+
restart_space()
|
44 |
+
try:
|
45 |
+
snapshot_download(
|
46 |
+
repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, token=TOKEN, repo_type="dataset", tqdm_class=None, etag_timeout=30
|
47 |
+
)
|
48 |
+
except Exception:
|
49 |
+
restart_space()
|
50 |
+
|
51 |
+
raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
52 |
+
leaderboard_df = original_df.copy()
|
53 |
+
|
54 |
+
(
|
55 |
+
finished_eval_queue_df,
|
56 |
+
running_eval_queue_df,
|
57 |
+
pending_eval_queue_df,
|
58 |
+
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
59 |
+
|
60 |
+
|
61 |
+
# Searching and filtering
|
62 |
+
def update_table(
|
63 |
+
hidden_df: pd.DataFrame,
|
64 |
+
columns: list,
|
65 |
+
type_query: list,
|
66 |
+
precision_query: str,
|
67 |
+
size_query: list,
|
68 |
+
show_deleted: bool,
|
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, filtered_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 |
+
return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
|
79 |
+
|
80 |
+
|
81 |
+
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
82 |
+
always_here_cols = [
|
83 |
+
#AutoEvalColumn.model_type_symbol.name,
|
84 |
+
AutoEvalColumn.model.name,
|
85 |
+
]
|
86 |
+
# We use COLS to maintain sorting
|
87 |
+
filtered_df = df[
|
88 |
+
always_here_cols + [c for c in COLS if c in df.columns and c in columns] + [AutoEvalColumn.dummy.name]
|
89 |
+
]
|
90 |
+
return filtered_df
|
91 |
+
|
92 |
+
|
93 |
+
def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
|
94 |
+
final_df = []
|
95 |
+
if query != "":
|
96 |
+
queries = [q.strip() for q in query.split(";")]
|
97 |
+
for _q in queries:
|
98 |
+
_q = _q.strip()
|
99 |
+
if _q != "":
|
100 |
+
temp_filtered_df = search_table(filtered_df, _q)
|
101 |
+
if len(temp_filtered_df) > 0:
|
102 |
+
final_df.append(temp_filtered_df)
|
103 |
+
if len(final_df) > 0:
|
104 |
+
filtered_df = pd.concat(final_df)
|
105 |
+
filtered_df = filtered_df.drop_duplicates(
|
106 |
+
subset=[AutoEvalColumn.model.name, AutoEvalColumn.precision.name, AutoEvalColumn.revision.name]
|
107 |
+
)
|
108 |
+
|
109 |
+
return filtered_df
|
110 |
+
|
111 |
+
|
112 |
+
def filter_models(
|
113 |
+
df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
|
114 |
+
) -> pd.DataFrame:
|
115 |
+
# Show all models
|
116 |
+
if show_deleted:
|
117 |
+
filtered_df = df
|
118 |
+
else: # Show only still on the hub models
|
119 |
+
filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
|
120 |
+
|
121 |
+
type_emoji = [t[0] for t in type_query]
|
122 |
+
#filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
|
123 |
+
filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
|
124 |
+
|
125 |
+
numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
|
126 |
+
params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
|
127 |
+
mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
128 |
+
filtered_df = filtered_df.loc[mask]
|
129 |
+
|
130 |
+
return filtered_df
|
131 |
+
|
132 |
+
|
133 |
+
demo = gr.Blocks(css=custom_css)
|
134 |
+
with demo:
|
135 |
+
gr.HTML(TITLE)
|
136 |
+
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
137 |
+
|
138 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
139 |
+
with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
140 |
+
with gr.Row():
|
141 |
+
search_bar = gr.Textbox(
|
142 |
+
placeholder=" 🔍 Search for your model (separate multiple queries with `;`) and press ENTER...",
|
143 |
+
show_label=False,
|
144 |
+
elem_id="search-bar",
|
145 |
+
)
|
146 |
+
with gr.Row():
|
147 |
+
shown_columns = gr.CheckboxGroup(
|
148 |
+
choices=[
|
149 |
+
c.name
|
150 |
+
for c in fields(AutoEvalColumn)
|
151 |
+
if not c.hidden and not c.never_hidden and not c.dummy
|
152 |
+
],
|
153 |
+
value=[
|
154 |
+
c.name
|
155 |
+
for c in fields(AutoEvalColumn)
|
156 |
+
if c.displayed_by_default and not c.hidden and not c.never_hidden
|
157 |
+
],
|
158 |
+
label="Select columns to show",
|
159 |
+
elem_id="column-select",
|
160 |
+
interactive=True,
|
161 |
+
)
|
162 |
+
with gr.Row():
|
163 |
+
with gr.Column():
|
164 |
+
with gr.Row(elem_id="box-filter"):
|
165 |
+
deleted_models_visibility = gr.Checkbox(
|
166 |
+
value=True, label="Show gated/private/deleted models", interactive=True,
|
167 |
+
)
|
168 |
+
filter_columns_type = gr.CheckboxGroup(
|
169 |
+
label="Model types",
|
170 |
+
choices=[t.to_str() for t in ModelType],
|
171 |
+
value=[t.to_str() for t in ModelType],
|
172 |
+
interactive=True,
|
173 |
+
elem_id="filter-columns-type",
|
174 |
+
visible=False,
|
175 |
+
)
|
176 |
+
filter_columns_precision = gr.CheckboxGroup(
|
177 |
+
label="Precision",
|
178 |
+
choices=[i.value.name for i in Precision],
|
179 |
+
value=[i.value.name for i in Precision],
|
180 |
+
interactive=True,
|
181 |
+
elem_id="filter-columns-precision",
|
182 |
+
visible=False,
|
183 |
+
)
|
184 |
+
filter_columns_size = gr.CheckboxGroup(
|
185 |
+
label="Model sizes (in billions of parameters)",
|
186 |
+
choices=list(NUMERIC_INTERVALS.keys()),
|
187 |
+
value=list(NUMERIC_INTERVALS.keys()),
|
188 |
+
interactive=True,
|
189 |
+
elem_id="filter-columns-size",
|
190 |
+
visible=False,
|
191 |
+
)
|
192 |
+
|
193 |
+
leaderboard_table = gr.components.Dataframe(
|
194 |
+
value=leaderboard_df[
|
195 |
+
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
196 |
+
+ shown_columns.value
|
197 |
+
+ [AutoEvalColumn.dummy.name]
|
198 |
+
],
|
199 |
+
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
200 |
+
datatype=TYPES,
|
201 |
+
elem_id="leaderboard-table",
|
202 |
+
interactive=False,
|
203 |
+
visible=True,
|
204 |
+
column_widths=["33%"] #"2%",
|
205 |
+
)
|
206 |
+
|
207 |
+
# Dummy leaderboard for handling the case when the user uses backspace key
|
208 |
+
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
209 |
+
value=original_df[COLS],
|
210 |
+
headers=COLS,
|
211 |
+
datatype=TYPES,
|
212 |
+
visible=False,
|
213 |
+
)
|
214 |
+
search_bar.submit(
|
215 |
+
update_table,
|
216 |
+
[
|
217 |
+
hidden_leaderboard_table_for_search,
|
218 |
+
shown_columns,
|
219 |
+
filter_columns_type,
|
220 |
+
filter_columns_precision,
|
221 |
+
filter_columns_size,
|
222 |
+
deleted_models_visibility,
|
223 |
+
search_bar,
|
224 |
+
],
|
225 |
+
leaderboard_table,
|
226 |
+
)
|
227 |
+
for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility]:
|
228 |
+
selector.change(
|
229 |
+
update_table,
|
230 |
+
[
|
231 |
+
hidden_leaderboard_table_for_search,
|
232 |
+
shown_columns,
|
233 |
+
filter_columns_type,
|
234 |
+
filter_columns_precision,
|
235 |
+
filter_columns_size,
|
236 |
+
deleted_models_visibility,
|
237 |
+
search_bar,
|
238 |
+
],
|
239 |
+
leaderboard_table,
|
240 |
+
queue=True,
|
241 |
+
)
|
242 |
+
|
243 |
+
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
244 |
+
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
245 |
+
|
246 |
+
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
247 |
+
with gr.Column():
|
248 |
+
with gr.Row():
|
249 |
+
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
250 |
+
|
251 |
+
with gr.Column():
|
252 |
+
with gr.Accordion(
|
253 |
+
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
254 |
+
open=False,
|
255 |
+
):
|
256 |
+
with gr.Row():
|
257 |
+
finished_eval_table = gr.components.Dataframe(
|
258 |
+
value=finished_eval_queue_df,
|
259 |
+
headers=EVAL_COLS,
|
260 |
+
datatype=EVAL_TYPES,
|
261 |
+
row_count=5,
|
262 |
+
)
|
263 |
+
with gr.Accordion(
|
264 |
+
f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
|
265 |
+
open=False,
|
266 |
+
):
|
267 |
+
with gr.Row():
|
268 |
+
running_eval_table = gr.components.Dataframe(
|
269 |
+
value=running_eval_queue_df,
|
270 |
+
headers=EVAL_COLS,
|
271 |
+
datatype=EVAL_TYPES,
|
272 |
+
row_count=5,
|
273 |
+
)
|
274 |
+
|
275 |
+
with gr.Accordion(
|
276 |
+
f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
277 |
+
open=False,
|
278 |
+
):
|
279 |
+
with gr.Row():
|
280 |
+
pending_eval_table = gr.components.Dataframe(
|
281 |
+
value=pending_eval_queue_df,
|
282 |
+
headers=EVAL_COLS,
|
283 |
+
datatype=EVAL_TYPES,
|
284 |
+
row_count=5,
|
285 |
+
)
|
286 |
+
with gr.Row():
|
287 |
+
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
288 |
+
|
289 |
+
with gr.Row():
|
290 |
+
with gr.Column():
|
291 |
+
model_name_textbox = gr.Textbox(label="Model name")
|
292 |
+
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
293 |
+
model_type = gr.Dropdown(
|
294 |
+
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
295 |
+
label="Model type",
|
296 |
+
multiselect=False,
|
297 |
+
value=None,
|
298 |
+
interactive=True,
|
299 |
+
)
|
300 |
+
|
301 |
+
with gr.Column():
|
302 |
+
precision = gr.Dropdown(
|
303 |
+
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
304 |
+
label="Precision",
|
305 |
+
multiselect=False,
|
306 |
+
value="float16",
|
307 |
+
interactive=True,
|
308 |
+
)
|
309 |
+
weight_type = gr.Dropdown(
|
310 |
+
choices=[i.value.name for i in WeightType],
|
311 |
+
label="Weights type",
|
312 |
+
multiselect=False,
|
313 |
+
value="Original",
|
314 |
+
interactive=True,
|
315 |
+
)
|
316 |
+
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
317 |
+
|
318 |
+
submit_button = gr.Button("Submit Eval")
|
319 |
+
submission_result = gr.Markdown()
|
320 |
+
submit_button.click(
|
321 |
+
add_new_eval,
|
322 |
+
[
|
323 |
+
model_name_textbox,
|
324 |
+
base_model_name_textbox,
|
325 |
+
revision_name_textbox,
|
326 |
+
precision,
|
327 |
+
weight_type,
|
328 |
+
model_type,
|
329 |
+
],
|
330 |
+
submission_result,
|
331 |
+
)
|
332 |
+
with gr.TabItem("🤓 Support us", elem_id="support-page", id=4):
|
333 |
+
gr.Markdown(OCCIGLOT_SUPPORT, elem_classes="markdown-text")
|
334 |
+
|
335 |
+
with gr.Row():
|
336 |
+
with gr.Accordion("📙 Citation", open=False):
|
337 |
+
citation_button = gr.Textbox(
|
338 |
+
value=CITATION_BUTTON_TEXT,
|
339 |
+
label=CITATION_BUTTON_LABEL,
|
340 |
+
lines=20,
|
341 |
+
elem_id="citation-button",
|
342 |
+
show_copy_button=True,
|
343 |
+
)
|
344 |
+
|
345 |
+
scheduler = BackgroundScheduler()
|
346 |
+
scheduler.add_job(restart_space, "interval", seconds=1800)
|
347 |
+
scheduler.start()
|
348 |
+
demo.queue(default_concurrency_limit=40).launch()
|
pyproject.toml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[tool.ruff]
|
2 |
+
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
|
3 |
+
select = ["E", "F"]
|
4 |
+
ignore = ["E501"] # line too long (black is taking care of this)
|
5 |
+
line-length = 119
|
6 |
+
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
|
7 |
+
|
8 |
+
[tool.isort]
|
9 |
+
profile = "black"
|
10 |
+
line_length = 119
|
11 |
+
|
12 |
+
[tool.black]
|
13 |
+
line-length = 119
|
requirements.txt
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
APScheduler==3.10.1
|
2 |
+
black==23.11.0
|
3 |
+
click==8.1.3
|
4 |
+
datasets==2.14.5
|
5 |
+
gradio==4.4.0
|
6 |
+
gradio_client==0.7.0
|
7 |
+
huggingface-hub>=0.18.0
|
8 |
+
matplotlib==3.7.1
|
9 |
+
numpy==1.24.2
|
10 |
+
pandas==2.0.0
|
11 |
+
python-dateutil==2.8.2
|
12 |
+
requests==2.28.2
|
13 |
+
tqdm==4.65.0
|
14 |
+
transformers==4.35.2
|
15 |
+
tokenizers>=0.15.0
|
scripts/create_request_file.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import pprint
|
4 |
+
import re
|
5 |
+
from datetime import datetime, timezone
|
6 |
+
|
7 |
+
import click
|
8 |
+
from colorama import Fore
|
9 |
+
from huggingface_hub import HfApi, snapshot_download
|
10 |
+
|
11 |
+
EVAL_REQUESTS_PATH = "eval-queue"
|
12 |
+
QUEUE_REPO = "open-llm-leaderboard/requests"
|
13 |
+
|
14 |
+
precisions = ("float16", "bfloat16", "8bit (LLM.int8)", "4bit (QLoRA / FP4)", "GPTQ")
|
15 |
+
model_types = ("pretrained", "fine-tuned", "RL-tuned", "instruction-tuned")
|
16 |
+
weight_types = ("Original", "Delta", "Adapter")
|
17 |
+
|
18 |
+
|
19 |
+
def get_model_size(model_info, precision: str):
|
20 |
+
size_pattern = size_pattern = re.compile(r"(\d\.)?\d+(b|m)")
|
21 |
+
try:
|
22 |
+
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
23 |
+
except (AttributeError, TypeError):
|
24 |
+
try:
|
25 |
+
size_match = re.search(size_pattern, model_info.modelId.lower())
|
26 |
+
model_size = size_match.group(0)
|
27 |
+
model_size = round(float(model_size[:-1]) if model_size[-1] == "b" else float(model_size[:-1]) / 1e3, 3)
|
28 |
+
except AttributeError:
|
29 |
+
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
30 |
+
|
31 |
+
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
32 |
+
model_size = size_factor * model_size
|
33 |
+
return model_size
|
34 |
+
|
35 |
+
|
36 |
+
def main():
|
37 |
+
api = HfApi()
|
38 |
+
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
39 |
+
snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH, repo_type="dataset")
|
40 |
+
|
41 |
+
model_name = click.prompt("Enter model name")
|
42 |
+
revision = click.prompt("Enter revision", default="main")
|
43 |
+
precision = click.prompt("Enter precision", default="float16", type=click.Choice(precisions))
|
44 |
+
model_type = click.prompt("Enter model type", type=click.Choice(model_types))
|
45 |
+
weight_type = click.prompt("Enter weight type", default="Original", type=click.Choice(weight_types))
|
46 |
+
base_model = click.prompt("Enter base model", default="")
|
47 |
+
status = click.prompt("Enter status", default="FINISHED")
|
48 |
+
|
49 |
+
try:
|
50 |
+
model_info = api.model_info(repo_id=model_name, revision=revision)
|
51 |
+
except Exception as e:
|
52 |
+
print(f"{Fore.RED}Could not find model info for {model_name} on the Hub\n{e}{Fore.RESET}")
|
53 |
+
return 1
|
54 |
+
|
55 |
+
model_size = get_model_size(model_info=model_info, precision=precision)
|
56 |
+
|
57 |
+
try:
|
58 |
+
license = model_info.cardData["license"]
|
59 |
+
except Exception:
|
60 |
+
license = "?"
|
61 |
+
|
62 |
+
eval_entry = {
|
63 |
+
"model": model_name,
|
64 |
+
"base_model": base_model,
|
65 |
+
"revision": revision,
|
66 |
+
"private": False,
|
67 |
+
"precision": precision,
|
68 |
+
"weight_type": weight_type,
|
69 |
+
"status": status,
|
70 |
+
"submitted_time": current_time,
|
71 |
+
"model_type": model_type,
|
72 |
+
"likes": model_info.likes,
|
73 |
+
"params": model_size,
|
74 |
+
"license": license,
|
75 |
+
}
|
76 |
+
|
77 |
+
user_name = ""
|
78 |
+
model_path = model_name
|
79 |
+
if "/" in model_name:
|
80 |
+
user_name = model_name.split("/")[0]
|
81 |
+
model_path = model_name.split("/")[1]
|
82 |
+
|
83 |
+
pprint.pprint(eval_entry)
|
84 |
+
|
85 |
+
if click.confirm("Do you want to continue? This request file will be pushed to the hub"):
|
86 |
+
click.echo("continuing...")
|
87 |
+
|
88 |
+
out_dir = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
89 |
+
os.makedirs(out_dir, exist_ok=True)
|
90 |
+
out_path = f"{out_dir}/{model_path}_eval_request_{False}_{precision}_{weight_type}.json"
|
91 |
+
|
92 |
+
with open(out_path, "w") as f:
|
93 |
+
f.write(json.dumps(eval_entry))
|
94 |
+
|
95 |
+
api.upload_file(
|
96 |
+
path_or_fileobj=out_path,
|
97 |
+
path_in_repo=out_path.split(f"{EVAL_REQUESTS_PATH}/")[1],
|
98 |
+
repo_id=QUEUE_REPO,
|
99 |
+
repo_type="dataset",
|
100 |
+
commit_message=f"Add {model_name} to eval queue",
|
101 |
+
)
|
102 |
+
else:
|
103 |
+
click.echo("aborting...")
|
104 |
+
|
105 |
+
|
106 |
+
if __name__ == "__main__":
|
107 |
+
main()
|
src/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
src/display/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
src/display/about.py
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import dataclass
|
2 |
+
from enum import Enum
|
3 |
+
|
4 |
+
@dataclass
|
5 |
+
class Task:
|
6 |
+
benchmark: str
|
7 |
+
metric: str
|
8 |
+
col_name: str
|
9 |
+
|
10 |
+
@dataclass
|
11 |
+
class Language:
|
12 |
+
col_name: str
|
13 |
+
ln_abb: str
|
14 |
+
bele_abb: str
|
15 |
+
|
16 |
+
|
17 |
+
# Init: to update with your specific keys
|
18 |
+
class Tasks(Enum):
|
19 |
+
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
20 |
+
task0 = Task("harness|arc_challenge|25", "acc_norm,none", "🇬🇧ARC EN")
|
21 |
+
task1 = Task("harness|truthfulqa_mc2|0", "acc,none", "🇬🇧TruthfulQA EN")
|
22 |
+
task2 = Task("harness|belebele_eng_Latn|5", "acc_norm,none", "🇬🇧Belebele EN")
|
23 |
+
task3 = Task("harness|hellaswag|10", "acc,none", "🇬🇧HellaSwag EN")
|
24 |
+
task4 = Task("harness|hendrycksTest|5", "acc,none", "🇬🇧MMLU EN")
|
25 |
+
task5 = Task("harness|arc_challenge_m_de|25", "acc_norm,none", "🇩🇪ARC DE")
|
26 |
+
task6 = Task("harness|truthfulqa_mc2_m_de|0", "acc,none", "🇩🇪TruthfulQA DE")
|
27 |
+
task7 = Task("harness|belebele_deu_Latn|5", "acc_norm,none", "🇩🇪Belebele DE")
|
28 |
+
task8 = Task("harness|hellaswag_de|10", "acc_norm,none", "🇩🇪HellaSwag DE")
|
29 |
+
task9 = Task("harness|mmlu_m_de|5", "acc,none", "🇩🇪MMLU DE")
|
30 |
+
task10 = Task("harness|arc_challenge_m_fr|25", "acc_norm,none", "🇫🇷ARC FR")
|
31 |
+
task11 = Task("harness|truthfulqa_mc2_m_fr|0", "acc,none", "🇫🇷TruthfulQA FR")
|
32 |
+
task12 = Task("harness|belebele_fra_Latn|5", "acc_norm,none", "🇫🇷Belebele FR")
|
33 |
+
task13 = Task("harness|hellaswag_fr|10", "acc_norm,none", "🇫🇷HellaSwag FR")
|
34 |
+
task14 = Task("harness|mmlu_m_fr|5", "acc,none", "🇫🇷MMLU FR")
|
35 |
+
task15 = Task("harness|arc_challenge_m_it|25", "acc_norm,none", "🇮🇹ARC IT")
|
36 |
+
task16 = Task("harness|truthfulqa_mc2_m_it|0", "acc,none", "🇮🇹TruthfulQA IT")
|
37 |
+
task17 = Task("harness|belebele_ita_Latn|5", "acc_norm,none", "🇮🇹Belebele IT")
|
38 |
+
task18 = Task("harness|hellaswag_it|10", "acc_norm,none", "🇮🇹HellaSwag IT")
|
39 |
+
task19 = Task("harness|mmlu_m_it|5", "acc,none", "🇮🇹MMLU IT")
|
40 |
+
task20 = Task("harness|arc_challenge_m_es|25", "acc_norm,none", "🇪🇸ARC ES")
|
41 |
+
task21 = Task("harness|truthfulqa_mc2_m_es|0", "acc,none", "🇪🇸TruthfulQA ES")
|
42 |
+
task22 = Task("harness|belebele_spa_Latn|5", "acc_norm,none", "🇪🇸Belebele ES")
|
43 |
+
task23 = Task("harness|hellaswag_es|10", "acc_norm,none", "🇪🇸HellaSwag ES")
|
44 |
+
task24 = Task("harness|mmlu_m_es|5", "acc,none", "🇪🇸MMLU ES")
|
45 |
+
|
46 |
+
class Languages(Enum):
|
47 |
+
lng0 = Language("🇩🇪 DE", "de", "deu")
|
48 |
+
lng1 = Language("🇫🇷 FR", "fr", "fra")
|
49 |
+
lng2 = Language("🇮🇹 IT", "it", "ita")
|
50 |
+
lng3 = Language("🇪🇸 ES", "es", "spa")
|
51 |
+
lng4 = Language("🇬🇧 EN", "", "eng")
|
52 |
+
|
53 |
+
# Your leaderboard name
|
54 |
+
TITLE = """<h1 align="center" id="space-title">Occiglot Euro LLM Leaderboard</h1>"""
|
55 |
+
|
56 |
+
# What does your leaderboard evaluate?
|
57 |
+
INTRODUCTION_TEXT = """
|
58 |
+
<div border="2px">
|
59 |
+
<p style="float: left;"><img src="https://huggingface.co/datasets/malteos/images/resolve/main/occiglot.medium.png" alt="Image" style="width:200px; margin-right:10px;" border="2px"/></p>
|
60 |
+
|
61 |
+
<p border="2px">The Occiglot euro LLM leaderboard evaluates a subset of the tasks from the <a href="https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard" target="_blank">Open LLM Leaderboard</a> machine-translated into the four main languages from the <a href="https://github.com/nlp-uoregon/Okapi" target="_blank">Okapi benchmark</a> and <a href="https://arxiv.org/abs/2308.16884" target="_blank">Belebele </a> (French, Italian, German and Spanish).
|
62 |
+
|
63 |
+
The translated tasks are uploaded to a fork of the great [Eleuther AI Language Model Evaluation Harness](https://github.com/occiglot/euro-lm-evaluation-harness).
|
64 |
+
|
65 |
+
Disclaimer: A language is not represented by a country. Different languages can be spoken and spread in all countries around the globe. For the sake of simplicity, we have used flag emojis (🇬🇧🇮🇹🇫🇷🇪🇸🇩🇪) to represent the language, not the countries.</p>
|
66 |
+
</div>
|
67 |
+
"""
|
68 |
+
|
69 |
+
# Which evaluations are you running? how can people reproduce what you have?
|
70 |
+
LLM_BENCHMARKS_TEXT = """
|
71 |
+
## ABOUT
|
72 |
+
Disclaimer: This is a copy of the [Open LLM Leaderbaord](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) from Huggingface with the extension of the translated benchmarks.
|
73 |
+
With the plethora of large language models (LLMs) and chatbots being released week upon week, often with grandiose claims of their performance, it can be hard to filter out the genuine progress that is being made by the open-source community and which model is the current state of the art.
|
74 |
+
|
75 |
+
🤗 Submit a model for automated evaluation on the 🤗 GPU cluster on the "Submit" page!
|
76 |
+
The leaderboard's backend runs the great [Eleuther AI Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) - read more details below!
|
77 |
+
|
78 |
+
### Tasks
|
79 |
+
📈 We evaluate models on 5 key benchmarks using a fork of the <a href="https://github.com/EleutherAI/lm-evaluation-harness" target="_blank"> Eleuther AI Language Model Evaluation Harness </a>, a unified framework to test generative language models on a large number of different evaluation tasks.
|
80 |
+
|
81 |
+
- <a href="https://arxiv.org/abs/1803.05457" target="_blank"> AI2 Reasoning Challenge </a> (25-shot) - a set of grade-school science questions.
|
82 |
+
- <a href="https://arxiv.org/abs/1905.07830" target="_blank"> HellaSwag </a> (10-shot) - a test of commonsense inference, which is easy for humans (~95%) but challenging for SOTA models.
|
83 |
+
- <a href="https://arxiv.org/abs/2009.03300" target="_blank"> MMLU </a> (5-shot) - a test to measure a text model's multitask accuracy. The test covers 57 tasks including elementary mathematics, US history, computer science, law, and more.
|
84 |
+
- <a href="https://arxiv.org/abs/2109.07958" target="_blank"> TruthfulQA </a> (0-shot) - a test to measure a model's propensity to reproduce falsehoods commonly found online. Note: TruthfulQA is technically a 6-shot task in the Harness because each example is prepended with 6 Q/A pairs, even in the 0-shot setting.
|
85 |
+
- <a href="https://arxiv.org/abs/2308.16884" target="_blank"> Belebele </a> (5-shot) - a multilingual multiple-choice machine reading comprehension dataset derived from FLORES-200. It evaluates and compares language model performance across 122 languages.
|
86 |
+
|
87 |
+
For all these evaluations, a higher score is a better score.
|
88 |
+
We chose these benchmarks based on the og Leaderboard from [Huggingface](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) (+Belebele 👀).
|
89 |
+
|
90 |
+
We used translations of the first 4 benchmarks from the <a href="https://arxiv.org/abs/2308.16884" target="_blank">Evaluation Framework for Multilingual Large Language Models </a> which was released as a part of the <a href="https://arxiv.org/abs/2307.16039" target="_blank"> Okapi </a> framework: a benchmark for multilingual large language models (LLMs) of <a href="https://arxiv.org/abs/1803.05457" target="_blank"> AI2 Reasoning Challenge </a>, <a href="https://arxiv.org/abs/1905.07830" target="_blank"> HellaSwag </a>, <a href="https://arxiv.org/abs/2109.07958" target="_blank"> TruthfulQA </a>, and <a href="https://arxiv.org/abs/2009.03300" target="_blank"> MMLU </a>.
|
91 |
+
|
92 |
+
### Results
|
93 |
+
You can find:
|
94 |
+
- detailed numerical results in the `results` Hugging Face dataset: https://huggingface.co/datasets/occiglot/euro-llm-leaderboard-results
|
95 |
+
- details on the input/outputs for the models in the `details` of each model, which you can access by clicking the 📄 emoji after the model name
|
96 |
+
- community queries and running status in the `requests` Hugging Face dataset: https://huggingface.co/datasets/occiglot/euro-llm-leaderboard-requests
|
97 |
+
|
98 |
+
If a model's name contains "Flagged", this indicates it has been flagged by the community, and should probably be ignored! Clicking the link will redirect you to the discussion about the model.
|
99 |
+
|
100 |
+
---------------------------
|
101 |
+
|
102 |
+
## REPRODUCIBILITY
|
103 |
+
To reproduce our results, here are the commands you can run, using [this version](https://github.com/occiglot/euro-lm-evaluation-harness) of fork of the Eleuther AI Harness:
|
104 |
+
`python main.py --model hf --model_args "pretrained=<your_model>" --tasks <task_list> --num_fewshot <n_few_shot> --batch_size auto:4`
|
105 |
+
|
106 |
+
```
|
107 |
+
python main.py --model=hf-causal-experimental \
|
108 |
+
--model_args="pretrained=<your_model>" \
|
109 |
+
--tasks=<task_list> \
|
110 |
+
--num_fewshot=<n_few_shot> \
|
111 |
+
--batch_size=auto:4 \
|
112 |
+
--output_path=<output_path>
|
113 |
+
```
|
114 |
+
|
115 |
+
**Note:** We evaluate all models on a single node of one H100/A100-80GB.
|
116 |
+
*You can expect results to vary slightly for different batch sizes because of padding.*
|
117 |
+
|
118 |
+
The tasks and few shots parameters are:
|
119 |
+
- ARC: 25-shot, *arc-challenge,arc-challenge_m_de,arc-challenge_m_es,arc-challenge_m_it,arc-challenge_m_fr* (`acc_norm`)
|
120 |
+
- HellaSwag: 10-shot, *hellaswag,hellaswag_es,hellaswag_it,hellaswag_fr,hellaswag_de* (`acc_norm`)
|
121 |
+
- TruthfulQA: 0-shot, *truthfulqa-mc,truthfulqa_mc2_m_de,truthfulqa_mc2_m_fr,truthfulqa_mc2_m_es,truthfulqa_mc2_m_it* (`mc2`)
|
122 |
+
- MMLU: 5-shot, *hendrycksTest-abstract_algebra,hendrycksTest-anatomy,hendrycksTest-astronomy,hendrycksTest-business_ethics,hendrycksTest-clinical_knowledge,hendrycksTest-college_biology,hendrycksTest-college_chemistry,hendrycksTest-college_computer_science,hendrycksTest-college_mathematics,hendrycksTest-college_medicine,hendrycksTest-college_physics,hendrycksTest-computer_security,hendrycksTest-conceptual_physics,hendrycksTest-econometrics,hendrycksTest-electrical_engineering,hendrycksTest-elementary_mathematics,hendrycksTest-formal_logic,hendrycksTest-global_facts,hendrycksTest-high_school_biology,hendrycksTest-high_school_chemistry,hendrycksTest-high_school_computer_science,hendrycksTest-high_school_european_history,hendrycksTest-high_school_geography,hendrycksTest-high_school_government_and_politics,hendrycksTest-high_school_macroeconomics,hendrycksTest-high_school_mathematics,hendrycksTest-high_school_microeconomics,hendrycksTest-high_school_physics,hendrycksTest-high_school_psychology,hendrycksTest-high_school_statistics,hendrycksTest-high_school_us_history,hendrycksTest-high_school_world_history,hendrycksTest-human_aging,hendrycksTest-human_sexuality,hendrycksTest-international_law,hendrycksTest-jurisprudence,hendrycksTest-logical_fallacies,hendrycksTest-machine_learning,hendrycksTest-management,hendrycksTest-marketing,hendrycksTest-medical_genetics,hendrycksTest-miscellaneous,hendrycksTest-moral_disputes,hendrycksTest-moral_scenarios,hendrycksTest-nutrition,hendrycksTest-philosophy,hendrycksTest-prehistory,hendrycksTest-professional_accounting,hendrycksTest-professional_law,hendrycksTest-professional_medicine,hendrycksTest-professional_psychology,hendrycksTest-public_relations,hendrycksTest-security_studies,hendrycksTest-sociology,hendrycksTest-us_foreign_policy,hendrycksTest-virology,hendrycksTest-world_religions,mmlu_m_es,mmlu_m_fr,mmlu_m_it,mmlu_m_de* (average of all the results `acc`)
|
123 |
+
- Belebele: 5-shot, *belebel_eng_Latn,belebel_ita_Latn,belebel_deu_Latn,belebel_fra_Latn,belebel_spa_Latn* (`acc_norm`)
|
124 |
+
|
125 |
+
**Note:** The number of few shot parameters and the metric is identical for each benchmark across all translations.
|
126 |
+
|
127 |
+
Side note on the baseline scores:
|
128 |
+
- for log-likelihood evaluation, we select the random baseline
|
129 |
+
|
130 |
+
---------------------------
|
131 |
+
|
132 |
+
## RESOURCES
|
133 |
+
|
134 |
+
### Quantization
|
135 |
+
To get more information about quantization, see:
|
136 |
+
- 8 bits: [blog post](https://huggingface.co/blog/hf-bitsandbytes-integration), [paper](https://arxiv.org/abs/2208.07339)
|
137 |
+
- 4 bits: [blog post](https://huggingface.co/blog/4bit-transformers-bitsandbytes), [paper](https://arxiv.org/abs/2305.14314)
|
138 |
+
|
139 |
+
### Useful links
|
140 |
+
- [Community resources](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard/discussions/174)
|
141 |
+
- [Collection of best models](https://huggingface.co/collections/open-llm-leaderboard/llm-leaderboard-best-models-652d6c7965a4619fb5c27a03)
|
142 |
+
|
143 |
+
### Other cool leaderboards:
|
144 |
+
- [OG Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
|
145 |
+
- [LLM safety](https://huggingface.co/spaces/AI-Secure/llm-trustworthy-leaderboard)
|
146 |
+
- [LLM performance](https://huggingface.co/spaces/optimum/llm-perf-leaderboard)
|
147 |
+
|
148 |
+
|
149 |
+
"""
|
150 |
+
|
151 |
+
EVALUATION_QUEUE_TEXT = """
|
152 |
+
## Some good practices before submitting a model
|
153 |
+
|
154 |
+
### 1) Make sure you can load your model and tokenizer using AutoClasses:
|
155 |
+
```python
|
156 |
+
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
157 |
+
config = AutoConfig.from_pretrained("your model name", revision=revision)
|
158 |
+
model = AutoModel.from_pretrained("your model name", revision=revision)
|
159 |
+
tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
|
160 |
+
```
|
161 |
+
If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
|
162 |
+
|
163 |
+
Note: make sure your model is public!
|
164 |
+
Note: if your model needs `use_remote_code=True`, we do not support this option yet but we are working on adding it, stay posted!
|
165 |
+
|
166 |
+
### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
|
167 |
+
It's a new format for storing weights which is safer and faster to load and use. It will also allow us to add the number of parameters of your model to the `Extended Viewer`!
|
168 |
+
|
169 |
+
### 3) Make sure your model has an open license!
|
170 |
+
This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
|
171 |
+
|
172 |
+
### 4) Fill up your model card
|
173 |
+
When we add extra information about models to the leaderboard, it will be automatically taken from the model card
|
174 |
+
|
175 |
+
## In case of model failure
|
176 |
+
If your model is displayed in the `FAILED` category, its execution stopped.
|
177 |
+
Make sure you have followed the above steps first.
|
178 |
+
If everything is done, check you can launch the EleutherAIHarness on your model locally, using the above command without modifications (you can add `--limit` to limit the number of examples per task).
|
179 |
+
"""
|
180 |
+
|
181 |
+
OCCIGLOT_SUPPORT = """
|
182 |
+
Occiglot is an ongoing research collective for open-source language models for and by Europe.
|
183 |
+
We strongly believe in transparent research and exchange of ideas. If you are working on topics
|
184 |
+
relevant to European LLMs or seek to contribute to Occiglot, don't hesitate to get in touch with us or join our [Discord](https://discord.com/invite/wUpvYs4XvM)
|
185 |
+
server. **We are actively seeking collaborations!**
|
186 |
+
"""
|
187 |
+
|
188 |
+
CITATION_BUTTON_LABEL = """#
|
189 |
+
Copy the following snippet to cite these results:
|
190 |
+
"""
|
191 |
+
|
192 |
+
CITATION_BUTTON_TEXT = r"""@misc{OcciglotEuroLeaderboard,
|
193 |
+
author = {Barth, Fabio and Brack, Manuel and Kraus, Maurice and Ortiz Suarez, Pedro and Ostendorf, Malte and Schramowski, Patrick},
|
194 |
+
title = {Occiglot Euro LLM Leaderboard},
|
195 |
+
month = 3,
|
196 |
+
year = 2024,
|
197 |
+
version = {v0.0.1},
|
198 |
+
url = {https://huggingface.co/spaces/occiglot/euro-llm-leaderboard}"""
|
src/display/css_html_js.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
custom_css = """
|
2 |
+
|
3 |
+
.markdown-text {
|
4 |
+
font-size: 16px !important;
|
5 |
+
}
|
6 |
+
|
7 |
+
#models-to-add-text {
|
8 |
+
font-size: 18px !important;
|
9 |
+
}
|
10 |
+
|
11 |
+
#citation-button span {
|
12 |
+
font-size: 16px !important;
|
13 |
+
}
|
14 |
+
|
15 |
+
#citation-button textarea {
|
16 |
+
font-size: 16px !important;
|
17 |
+
}
|
18 |
+
|
19 |
+
#citation-button > label > button {
|
20 |
+
margin: 6px;
|
21 |
+
transform: scale(1.3);
|
22 |
+
}
|
23 |
+
|
24 |
+
#leaderboard-table {
|
25 |
+
margin-top: 15px
|
26 |
+
}
|
27 |
+
|
28 |
+
#leaderboard-table-lite {
|
29 |
+
margin-top: 15px
|
30 |
+
}
|
31 |
+
|
32 |
+
#search-bar-table-box > div:first-child {
|
33 |
+
background: none;
|
34 |
+
border: none;
|
35 |
+
}
|
36 |
+
|
37 |
+
#search-bar {
|
38 |
+
padding: 0px;
|
39 |
+
}
|
40 |
+
|
41 |
+
/* Hides the final AutoEvalColumn */
|
42 |
+
#llm-benchmark-tab-table table td:last-child,
|
43 |
+
#llm-benchmark-tab-table table th:last-child {
|
44 |
+
display: none;
|
45 |
+
}
|
46 |
+
|
47 |
+
/* Limit the width of the first AutoEvalColumn so that names don't expand too much */
|
48 |
+
table td:first-child,
|
49 |
+
table th:first-child {
|
50 |
+
max-width: 400px;
|
51 |
+
overflow: auto;
|
52 |
+
white-space: nowrap;
|
53 |
+
}
|
54 |
+
|
55 |
+
.tab-buttons button {
|
56 |
+
font-size: 20px;
|
57 |
+
}
|
58 |
+
|
59 |
+
#scale-logo {
|
60 |
+
border-style: none !important;
|
61 |
+
box-shadow: none;
|
62 |
+
display: block;
|
63 |
+
margin-left: auto;
|
64 |
+
margin-right: auto;
|
65 |
+
max-width: 600px;
|
66 |
+
}
|
67 |
+
|
68 |
+
#scale-logo .download {
|
69 |
+
display: none;
|
70 |
+
}
|
71 |
+
#filter_type{
|
72 |
+
border: 0;
|
73 |
+
padding-left: 0;
|
74 |
+
padding-top: 0;
|
75 |
+
}
|
76 |
+
#filter_type label {
|
77 |
+
display: flex;
|
78 |
+
}
|
79 |
+
#filter_type label > span{
|
80 |
+
margin-top: var(--spacing-lg);
|
81 |
+
margin-right: 0.5em;
|
82 |
+
}
|
83 |
+
#filter_type label > .wrap{
|
84 |
+
width: 103px;
|
85 |
+
}
|
86 |
+
#filter_type label > .wrap .wrap-inner{
|
87 |
+
padding: 2px;
|
88 |
+
}
|
89 |
+
#filter_type label > .wrap .wrap-inner input{
|
90 |
+
width: 1px
|
91 |
+
}
|
92 |
+
#filter-columns-type{
|
93 |
+
border:0;
|
94 |
+
padding:0.5;
|
95 |
+
}
|
96 |
+
#filter-columns-size{
|
97 |
+
border:0;
|
98 |
+
padding:0.5;
|
99 |
+
}
|
100 |
+
#box-filter > .form{
|
101 |
+
border: 0
|
102 |
+
}
|
103 |
+
"""
|
104 |
+
|
105 |
+
get_window_url_params = """
|
106 |
+
function(url_params) {
|
107 |
+
const params = new URLSearchParams(window.location.search);
|
108 |
+
url_params = Object.fromEntries(params);
|
109 |
+
return url_params;
|
110 |
+
}
|
111 |
+
"""
|
src/display/formatting.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from datetime import datetime, timezone
|
3 |
+
|
4 |
+
from huggingface_hub import HfApi
|
5 |
+
from huggingface_hub.hf_api import ModelInfo
|
6 |
+
|
7 |
+
|
8 |
+
API = HfApi()
|
9 |
+
|
10 |
+
def model_hyperlink(link, model_name):
|
11 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
12 |
+
|
13 |
+
|
14 |
+
def make_clickable_model(model_name):
|
15 |
+
link = f"https://huggingface.co/{model_name}"
|
16 |
+
return model_hyperlink(link, model_name)
|
17 |
+
|
18 |
+
|
19 |
+
def styled_error(error):
|
20 |
+
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
|
21 |
+
|
22 |
+
|
23 |
+
def styled_warning(warn):
|
24 |
+
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
|
25 |
+
|
26 |
+
|
27 |
+
def styled_message(message):
|
28 |
+
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|
29 |
+
|
30 |
+
|
31 |
+
def has_no_nan_values(df, columns):
|
32 |
+
return df[columns].notna().all(axis=1)
|
33 |
+
|
34 |
+
|
35 |
+
def has_nan_values(df, columns):
|
36 |
+
return df[columns].isna().any(axis=1)
|
src/display/pictures/occiglot.medium.png
ADDED
src/display/utils.py
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import dataclass, make_dataclass
|
2 |
+
from enum import Enum
|
3 |
+
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
from src.display.about import Tasks, Languages
|
7 |
+
|
8 |
+
def fields(raw_class):
|
9 |
+
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
10 |
+
|
11 |
+
|
12 |
+
# These classes are for user facing column names,
|
13 |
+
# to avoid having to change them all around the code
|
14 |
+
# when a modif is needed
|
15 |
+
@dataclass
|
16 |
+
class ColumnContent:
|
17 |
+
name: str
|
18 |
+
type: str
|
19 |
+
displayed_by_default: bool
|
20 |
+
hidden: bool = False
|
21 |
+
never_hidden: bool = False
|
22 |
+
dummy: bool = False
|
23 |
+
|
24 |
+
## Leaderboard columns
|
25 |
+
auto_eval_column_dict = []
|
26 |
+
# Init
|
27 |
+
auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", False, True ,never_hidden=False)])
|
28 |
+
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
29 |
+
#Scores
|
30 |
+
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("🇪🇺 Average ⬆️", "number", True)])
|
31 |
+
for lang in Languages:
|
32 |
+
auto_eval_column_dict.append([lang.name, ColumnContent, ColumnContent(lang.value.col_name, "number", True)])
|
33 |
+
|
34 |
+
for task in Tasks:
|
35 |
+
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", False)])
|
36 |
+
|
37 |
+
# Model information
|
38 |
+
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False, never_hidden=False, dummy=True)])
|
39 |
+
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False, never_hidden=False, dummy=True)])
|
40 |
+
auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, never_hidden=False, dummy=True)])
|
41 |
+
auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False, never_hidden=False, dummy=True)])
|
42 |
+
auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False, never_hidden=False, dummy=True)])
|
43 |
+
auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False, never_hidden=False, dummy=True)])
|
44 |
+
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False, never_hidden=False, dummy=True)])
|
45 |
+
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False, never_hidden=False, dummy=True)])
|
46 |
+
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False, never_hidden=False, dummy=True)])
|
47 |
+
# Dummy column for the search bar (hidden by the custom CSS)
|
48 |
+
auto_eval_column_dict.append(["dummy", ColumnContent, ColumnContent("model_name_for_query", "str", False, dummy=True)])
|
49 |
+
|
50 |
+
# We use make dataclass to dynamically fill the scores from Tasks
|
51 |
+
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
52 |
+
|
53 |
+
## For the queue columns in the submission tab
|
54 |
+
@dataclass(frozen=True)
|
55 |
+
class EvalQueueColumn: # Queue column
|
56 |
+
model = ColumnContent("model", "markdown", True)
|
57 |
+
revision = ColumnContent("revision", "str", True)
|
58 |
+
private = ColumnContent("private", "bool", True)
|
59 |
+
precision = ColumnContent("precision", "str", True)
|
60 |
+
weight_type = ColumnContent("weight_type", "str", "Original")
|
61 |
+
status = ColumnContent("status", "str", True)
|
62 |
+
|
63 |
+
## All the model information that we might need
|
64 |
+
@dataclass
|
65 |
+
class ModelDetails:
|
66 |
+
name: str
|
67 |
+
display_name: str = ""
|
68 |
+
symbol: str = "" # emoji
|
69 |
+
|
70 |
+
|
71 |
+
class ModelType(Enum):
|
72 |
+
PT = ModelDetails(name="pretrained", symbol="🟢")
|
73 |
+
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
74 |
+
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
75 |
+
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
76 |
+
Unknown = ModelDetails(name="", symbol="?")
|
77 |
+
|
78 |
+
def to_str(self, separator=" "):
|
79 |
+
return f"{self.value.symbol}{separator}{self.value.name}"
|
80 |
+
|
81 |
+
@staticmethod
|
82 |
+
def from_str(type):
|
83 |
+
if "fine-tuned" in type or "🔶" in type:
|
84 |
+
return ModelType.FT
|
85 |
+
if "pretrained" in type or "🟢" in type:
|
86 |
+
return ModelType.PT
|
87 |
+
if "RL-tuned" in type or "🟦" in type:
|
88 |
+
return ModelType.RL
|
89 |
+
if "instruction-tuned" in type or "⭕" in type:
|
90 |
+
return ModelType.IFT
|
91 |
+
return ModelType.Unknown
|
92 |
+
|
93 |
+
class WeightType(Enum):
|
94 |
+
Adapter = ModelDetails("Adapter")
|
95 |
+
Original = ModelDetails("Original")
|
96 |
+
Delta = ModelDetails("Delta")
|
97 |
+
|
98 |
+
class Precision(Enum):
|
99 |
+
float16 = ModelDetails("float16")
|
100 |
+
bfloat16 = ModelDetails("bfloat16")
|
101 |
+
qt_8bit = ModelDetails("8bit")
|
102 |
+
qt_4bit = ModelDetails("4bit")
|
103 |
+
qt_GPTQ = ModelDetails("GPTQ")
|
104 |
+
Unknown = ModelDetails("?")
|
105 |
+
|
106 |
+
def from_str(precision):
|
107 |
+
if precision in ["torch.float16", "float16"]:
|
108 |
+
return Precision.float16
|
109 |
+
if precision in ["torch.bfloat16", "bfloat16"]:
|
110 |
+
return Precision.bfloat16
|
111 |
+
if precision in ["8bit"]:
|
112 |
+
return Precision.qt_8bit
|
113 |
+
if precision in ["4bit"]:
|
114 |
+
return Precision.qt_4bit
|
115 |
+
if precision in ["GPTQ", "None"]:
|
116 |
+
return Precision.qt_GPTQ
|
117 |
+
return Precision.Unknown
|
118 |
+
|
119 |
+
# Column selection
|
120 |
+
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
121 |
+
TYPES = [c.type for c in fields(AutoEvalColumn) if not c.hidden]
|
122 |
+
COLS_LITE = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
123 |
+
TYPES_LITE = [c.type for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
124 |
+
|
125 |
+
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
126 |
+
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
127 |
+
|
128 |
+
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
129 |
+
|
130 |
+
NUMERIC_INTERVALS = {
|
131 |
+
"?": pd.Interval(-1, 0, closed="right"),
|
132 |
+
"~1.5": pd.Interval(0, 2, closed="right"),
|
133 |
+
"~3": pd.Interval(2, 4, closed="right"),
|
134 |
+
"~7": pd.Interval(4, 9, closed="right"),
|
135 |
+
"~13": pd.Interval(9, 20, closed="right"),
|
136 |
+
"~35": pd.Interval(20, 45, closed="right"),
|
137 |
+
"~60": pd.Interval(45, 70, closed="right"),
|
138 |
+
"70+": pd.Interval(70, 10000, closed="right"),
|
139 |
+
}
|
src/envs.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from huggingface_hub import HfApi
|
4 |
+
|
5 |
+
# clone / pull the lmeh eval data
|
6 |
+
TOKEN = os.environ.get("TOKEN", None)
|
7 |
+
|
8 |
+
OWNER = "occiglot"
|
9 |
+
REPO_ID = f"{OWNER}/euro-llm-leaderboard"
|
10 |
+
QUEUE_REPO = f"{OWNER}/euro-llm-leaderboard-requests"
|
11 |
+
RESULTS_REPO = f"{OWNER}/euro-llm-leaderboard-results"
|
12 |
+
|
13 |
+
CACHE_PATH=os.getenv("HF_HOME", ".")
|
14 |
+
|
15 |
+
# Local caches
|
16 |
+
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
17 |
+
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
18 |
+
|
19 |
+
API = HfApi(token=TOKEN)
|
src/leaderboard/read_evals.py
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import glob
|
2 |
+
import json
|
3 |
+
import math
|
4 |
+
import os
|
5 |
+
from dataclasses import dataclass
|
6 |
+
|
7 |
+
import dateutil
|
8 |
+
import numpy as np
|
9 |
+
|
10 |
+
from src.display.formatting import make_clickable_model
|
11 |
+
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType, Languages
|
12 |
+
from src.submission.check_validity import is_model_on_hub
|
13 |
+
|
14 |
+
|
15 |
+
@dataclass
|
16 |
+
class EvalResult:
|
17 |
+
eval_name: str # org_model_precision (uid)
|
18 |
+
full_model: str # org/model (path on hub)
|
19 |
+
org: str
|
20 |
+
model: str
|
21 |
+
revision: str # commit hash, "" if main
|
22 |
+
results: dict
|
23 |
+
precision: Precision = Precision.Unknown
|
24 |
+
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
25 |
+
weight_type: WeightType = WeightType.Original # Original or Adapter
|
26 |
+
architecture: str = "Unknown"
|
27 |
+
license: str = "?"
|
28 |
+
likes: int = 0
|
29 |
+
num_params: int = 0
|
30 |
+
date: str = "" # submission date of request file
|
31 |
+
still_on_hub: bool = False
|
32 |
+
|
33 |
+
@classmethod
|
34 |
+
def init_from_json_file(self, json_filepath):
|
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_general")
|
40 |
+
|
41 |
+
# Precision
|
42 |
+
precision = Precision.from_str(config.get("model_dtype"))
|
43 |
+
|
44 |
+
# Get model and org
|
45 |
+
org_and_model = config.get("model_name", config.get("model_args", None))
|
46 |
+
org_and_model = org_and_model.split("/", 1)
|
47 |
+
|
48 |
+
if len(org_and_model) == 1:
|
49 |
+
org = None
|
50 |
+
model = org_and_model[0]
|
51 |
+
result_key = f"{model}_{precision.value.name}"
|
52 |
+
else:
|
53 |
+
org = org_and_model[0]
|
54 |
+
model = org_and_model[1]
|
55 |
+
result_key = f"{org}_{model}_{precision.value.name}"
|
56 |
+
full_model = "/".join(org_and_model)
|
57 |
+
|
58 |
+
still_on_hub, _, model_config = is_model_on_hub(
|
59 |
+
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
60 |
+
)
|
61 |
+
architecture = "?"
|
62 |
+
if model_config is not None:
|
63 |
+
architectures = getattr(model_config, "architectures", None)
|
64 |
+
if architectures:
|
65 |
+
architecture = ";".join(architectures)
|
66 |
+
|
67 |
+
# Extract results available in this file (some results are split in several files)
|
68 |
+
results = {}
|
69 |
+
for task in Tasks:
|
70 |
+
task = task.value
|
71 |
+
|
72 |
+
# We average all scores of a given metric (not all metrics are present in all files)
|
73 |
+
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
74 |
+
if accs.size == 0 or any([acc is None for acc in accs]):
|
75 |
+
continue
|
76 |
+
|
77 |
+
mean_acc = np.mean(accs) * 100.0
|
78 |
+
results[task.benchmark] = mean_acc
|
79 |
+
|
80 |
+
return self(
|
81 |
+
eval_name=result_key,
|
82 |
+
full_model=full_model,
|
83 |
+
org=org,
|
84 |
+
model=model,
|
85 |
+
results=results,
|
86 |
+
precision=precision,
|
87 |
+
revision= config.get("model_sha", ""),
|
88 |
+
still_on_hub=still_on_hub,
|
89 |
+
architecture=architecture
|
90 |
+
)
|
91 |
+
|
92 |
+
def update_with_request_file(self, requests_path):
|
93 |
+
"""Finds the relevant request file for the current model and updates info with it"""
|
94 |
+
request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
|
95 |
+
|
96 |
+
try:
|
97 |
+
with open(request_file, "r") as f:
|
98 |
+
request = json.load(f)
|
99 |
+
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
100 |
+
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
101 |
+
self.license = request.get("license", "?")
|
102 |
+
self.likes = request.get("likes", 0)
|
103 |
+
self.num_params = request.get("params", 0)
|
104 |
+
self.date = request.get("submitted_time", "")
|
105 |
+
except Exception:
|
106 |
+
print(f"Could not find request file for {self.org}/{self.model}")
|
107 |
+
|
108 |
+
def to_dict(self):
|
109 |
+
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
110 |
+
average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
111 |
+
data_dict = {
|
112 |
+
"eval_name": self.eval_name, # not a column, just a save name,
|
113 |
+
AutoEvalColumn.precision.name: self.precision.value.name,
|
114 |
+
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
115 |
+
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
116 |
+
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
117 |
+
AutoEvalColumn.architecture.name: self.architecture,
|
118 |
+
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
119 |
+
AutoEvalColumn.dummy.name: self.full_model,
|
120 |
+
AutoEvalColumn.revision.name: self.revision,
|
121 |
+
AutoEvalColumn.average.name: average,
|
122 |
+
AutoEvalColumn.license.name: self.license,
|
123 |
+
AutoEvalColumn.likes.name: self.likes,
|
124 |
+
AutoEvalColumn.params.name: self.num_params,
|
125 |
+
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
126 |
+
}
|
127 |
+
|
128 |
+
for language in Languages:
|
129 |
+
# FIX: for english only
|
130 |
+
if not language.value.ln_abb:
|
131 |
+
lng_result = [self.results["harness|arc_challenge|25"], self.results["harness|truthfulqa_mc2|0"], self.results["harness|belebele_eng_Latn|5"], self.results["harness|hellaswag|10"], self.results["harness|hendrycksTest|5"]]
|
132 |
+
else:
|
133 |
+
lng_result = [v for k, v in self.results.items() if v is not None and (f"_{language.value.ln_abb}" in k or f"_{language.value.ln_abb}" in k)]
|
134 |
+
data_dict[language.value.col_name] = sum(lng_result) / len(lng_result)
|
135 |
+
|
136 |
+
for task in Tasks:
|
137 |
+
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
138 |
+
|
139 |
+
return data_dict
|
140 |
+
|
141 |
+
|
142 |
+
def get_request_file_for_model(requests_path, model_name, precision):
|
143 |
+
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
144 |
+
request_files = os.path.join(
|
145 |
+
requests_path,
|
146 |
+
f"{model_name}_eval_request_*.json",
|
147 |
+
)
|
148 |
+
request_files = glob.glob(request_files)
|
149 |
+
|
150 |
+
# Select correct request file (precision)
|
151 |
+
request_file = ""
|
152 |
+
request_files = sorted(request_files, reverse=True)
|
153 |
+
for tmp_request_file in request_files:
|
154 |
+
with open(tmp_request_file, "r") as f:
|
155 |
+
req_content = json.load(f)
|
156 |
+
if (
|
157 |
+
req_content["status"] in ["FINISHED"]
|
158 |
+
and req_content["precision"] == precision.split(".")[-1]
|
159 |
+
):
|
160 |
+
request_file = tmp_request_file
|
161 |
+
return request_file
|
162 |
+
|
163 |
+
|
164 |
+
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
165 |
+
"""From the path of the results folder root, extract all needed info for results"""
|
166 |
+
model_result_filepaths = []
|
167 |
+
|
168 |
+
for root, _, files in os.walk(results_path):
|
169 |
+
|
170 |
+
# We should only have json files in model results
|
171 |
+
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
172 |
+
continue
|
173 |
+
|
174 |
+
# Sort the files by date
|
175 |
+
try:
|
176 |
+
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
177 |
+
except dateutil.parser._parser.ParserError:
|
178 |
+
files = [files[-1]]
|
179 |
+
|
180 |
+
for file in files:
|
181 |
+
model_result_filepaths.append(os.path.join(root, file))
|
182 |
+
|
183 |
+
eval_results = {}
|
184 |
+
for model_result_filepath in model_result_filepaths:
|
185 |
+
# Creation of result
|
186 |
+
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
187 |
+
eval_result.update_with_request_file(requests_path)
|
188 |
+
|
189 |
+
# Store results of same eval together
|
190 |
+
eval_name = eval_result.eval_name
|
191 |
+
if eval_name in eval_results.keys():
|
192 |
+
eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
|
193 |
+
else:
|
194 |
+
eval_results[eval_name] = eval_result
|
195 |
+
|
196 |
+
results = []
|
197 |
+
for v in eval_results.values():
|
198 |
+
try:
|
199 |
+
v.to_dict() # we test if the dict version is complete
|
200 |
+
results.append(v)
|
201 |
+
except KeyError: # not all eval values present
|
202 |
+
continue
|
203 |
+
|
204 |
+
return results
|
src/populate.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
from src.display.formatting import has_no_nan_values, make_clickable_model
|
7 |
+
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
+
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
+
|
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(all_data_json)
|
15 |
+
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
16 |
+
df = df[cols].round(decimals=2)
|
17 |
+
|
18 |
+
# filter out if any of the benchmarks have not been produced
|
19 |
+
df = df[has_no_nan_values(df, benchmark_cols)]
|
20 |
+
return raw_data, df
|
21 |
+
|
22 |
+
|
23 |
+
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
24 |
+
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
25 |
+
all_evals = []
|
26 |
+
|
27 |
+
for entry in entries:
|
28 |
+
if ".json" in entry:
|
29 |
+
file_path = os.path.join(save_path, entry)
|
30 |
+
with open(file_path) as fp:
|
31 |
+
data = json.load(fp)
|
32 |
+
|
33 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
34 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
35 |
+
|
36 |
+
all_evals.append(data)
|
37 |
+
elif ".md" not in entry:
|
38 |
+
# this is a folder
|
39 |
+
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
|
40 |
+
for sub_entry in sub_entries:
|
41 |
+
file_path = os.path.join(save_path, entry, sub_entry)
|
42 |
+
with open(file_path) as fp:
|
43 |
+
data = json.load(fp)
|
44 |
+
|
45 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
46 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
47 |
+
all_evals.append(data)
|
48 |
+
|
49 |
+
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
50 |
+
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
51 |
+
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
52 |
+
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
53 |
+
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
54 |
+
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
55 |
+
return df_finished[cols], df_running[cols], df_pending[cols]
|
src/submission/check_validity.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
from collections import defaultdict
|
5 |
+
from datetime import datetime, timedelta, timezone
|
6 |
+
|
7 |
+
import huggingface_hub
|
8 |
+
from huggingface_hub import ModelCard
|
9 |
+
from huggingface_hub.hf_api import ModelInfo
|
10 |
+
from transformers import AutoConfig
|
11 |
+
from transformers.models.auto.tokenization_auto import tokenizer_class_from_name, get_tokenizer_config
|
12 |
+
|
13 |
+
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
14 |
+
"""Checks if the model card and license exist and have been filled"""
|
15 |
+
try:
|
16 |
+
card = ModelCard.load(repo_id)
|
17 |
+
except huggingface_hub.utils.EntryNotFoundError:
|
18 |
+
return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
|
19 |
+
|
20 |
+
# Enforce license metadata
|
21 |
+
if card.data.license is None:
|
22 |
+
if not ("license_name" in card.data and "license_link" in card.data):
|
23 |
+
return False, (
|
24 |
+
"License not found. Please add a license to your model card using the `license` metadata or a"
|
25 |
+
" `license_name`/`license_link` pair."
|
26 |
+
)
|
27 |
+
|
28 |
+
# Enforce card content
|
29 |
+
if len(card.text) < 200:
|
30 |
+
return False, "Please add a description to your model card, it is too short."
|
31 |
+
|
32 |
+
return True, ""
|
33 |
+
|
34 |
+
|
35 |
+
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
36 |
+
"""Makes sure the model is on the hub, and uses a valid configuration (in the latest transformers version)"""
|
37 |
+
try:
|
38 |
+
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
39 |
+
if test_tokenizer:
|
40 |
+
tokenizer_config = get_tokenizer_config(model_name)
|
41 |
+
if tokenizer_config is not None:
|
42 |
+
tokenizer_class_candidate = tokenizer_config.get("tokenizer_class", None)
|
43 |
+
else:
|
44 |
+
tokenizer_class_candidate = config.tokenizer_class
|
45 |
+
|
46 |
+
|
47 |
+
tokenizer_class = tokenizer_class_from_name(tokenizer_class_candidate)
|
48 |
+
if tokenizer_class is None:
|
49 |
+
return (
|
50 |
+
False,
|
51 |
+
f"uses {tokenizer_class_candidate}, which is not in a transformers release, therefore not supported at the moment.",
|
52 |
+
None
|
53 |
+
)
|
54 |
+
return True, None, config
|
55 |
+
|
56 |
+
except ValueError:
|
57 |
+
return (
|
58 |
+
False,
|
59 |
+
"needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",
|
60 |
+
None
|
61 |
+
)
|
62 |
+
|
63 |
+
except Exception as e:
|
64 |
+
return False, "was not found on hub!", None
|
65 |
+
|
66 |
+
|
67 |
+
def get_model_size(model_info: ModelInfo, precision: str):
|
68 |
+
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
69 |
+
try:
|
70 |
+
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
71 |
+
except (AttributeError, TypeError):
|
72 |
+
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
73 |
+
|
74 |
+
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
75 |
+
model_size = size_factor * model_size
|
76 |
+
return model_size
|
77 |
+
|
78 |
+
def get_model_arch(model_info: ModelInfo):
|
79 |
+
"""Gets the model architecture from the configuration"""
|
80 |
+
return model_info.config.get("architectures", "Unknown")
|
81 |
+
|
82 |
+
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
83 |
+
depth = 1
|
84 |
+
file_names = []
|
85 |
+
users_to_submission_dates = defaultdict(list)
|
86 |
+
|
87 |
+
for root, _, files in os.walk(requested_models_dir):
|
88 |
+
current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
|
89 |
+
if current_depth == depth:
|
90 |
+
for file in files:
|
91 |
+
if not file.endswith(".json"):
|
92 |
+
continue
|
93 |
+
with open(os.path.join(root, file), "r") as f:
|
94 |
+
info = json.load(f)
|
95 |
+
file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
|
96 |
+
|
97 |
+
# Select organisation
|
98 |
+
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
99 |
+
continue
|
100 |
+
organisation, _ = info["model"].split("/")
|
101 |
+
users_to_submission_dates[organisation].append(info["submitted_time"])
|
102 |
+
|
103 |
+
return set(file_names), users_to_submission_dates
|
src/submission/submit.py
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, 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 |
+
}
|
91 |
+
|
92 |
+
# Check for duplicate submission
|
93 |
+
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
94 |
+
return styled_warning("This model has been already submitted.")
|
95 |
+
|
96 |
+
print("Creating eval file")
|
97 |
+
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
98 |
+
os.makedirs(OUT_DIR, exist_ok=True)
|
99 |
+
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
100 |
+
|
101 |
+
with open(out_path, "w") as f:
|
102 |
+
f.write(json.dumps(eval_entry))
|
103 |
+
|
104 |
+
print("Uploading eval file")
|
105 |
+
API.upload_file(
|
106 |
+
path_or_fileobj=out_path,
|
107 |
+
path_in_repo=out_path.split("eval-queue/")[1],
|
108 |
+
repo_id=QUEUE_REPO,
|
109 |
+
repo_type="dataset",
|
110 |
+
commit_message=f"Add {model} to eval queue",
|
111 |
+
)
|
112 |
+
|
113 |
+
# Remove the local file
|
114 |
+
os.remove(out_path)
|
115 |
+
|
116 |
+
return styled_message(
|
117 |
+
"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."
|
118 |
+
)
|