gsaivinay edbeeching HF Staff commited on
Commit
9b74a5d
·
0 Parent(s):

Duplicate from HuggingFaceH4/open_llm_leaderboard

Browse files

Co-authored-by: Edward Beeching <[email protected]>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ scale-hf-logo.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ auto_evals/
2
+ venv/
3
+ __pycache__/
4
+ .env
5
+ .ipynb_checkpoints
6
+ *ipynb
7
+ .vscode/
8
+
9
+ gpt_4_evals/
10
+ human_evals/
11
+ eval-queue/
12
+ eval-results/
13
+ auto_evals/
14
+
15
+ src/assets/model_counts.html
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Open LLM Leaderboard
3
+ emoji: 🏆
4
+ colorFrom: green
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.27.0
8
+ app_file: app.py
9
+ pinned: true
10
+ license: apache-2.0
11
+ duplicated_from: HuggingFaceH4/open_llm_leaderboard
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ from datetime import datetime, timezone
4
+
5
+
6
+ import gradio as gr
7
+ import numpy as np
8
+ import pandas as pd
9
+ from apscheduler.schedulers.background import BackgroundScheduler
10
+ from huggingface_hub import HfApi
11
+ from transformers import AutoConfig
12
+
13
+ from src.auto_leaderboard.get_model_metadata import apply_metadata
14
+ from src.assets.text_content import *
15
+ from src.auto_leaderboard.load_results import get_eval_results_dicts, make_clickable_model
16
+ from src.assets.hardcoded_evals import gpt4_values, gpt35_values, baseline
17
+ from src.assets.css_html_js import custom_css, get_window_url_params
18
+ from src.utils_display import AutoEvalColumn, EvalQueueColumn, fields, styled_error, styled_warning, styled_message
19
+ from src.init import get_all_requested_models, load_all_info_from_hub
20
+
21
+ # clone / pull the lmeh eval data
22
+ H4_TOKEN = os.environ.get("H4_TOKEN", None)
23
+
24
+ QUEUE_REPO = "open-llm-leaderboard/requests"
25
+ RESULTS_REPO = "open-llm-leaderboard/results"
26
+
27
+ PRIVATE_QUEUE_REPO = "open-llm-leaderboard/private-requests"
28
+ PRIVATE_RESULTS_REPO = "open-llm-leaderboard/private-results"
29
+
30
+ IS_PUBLIC = bool(os.environ.get("IS_PUBLIC", True))
31
+
32
+ EVAL_REQUESTS_PATH = "eval-queue"
33
+ EVAL_RESULTS_PATH = "eval-results"
34
+
35
+ EVAL_REQUESTS_PATH_PRIVATE = "eval-queue-private"
36
+ EVAL_RESULTS_PATH_PRIVATE = "eval-results-private"
37
+
38
+ api = HfApi()
39
+
40
+ def restart_space():
41
+ api.restart_space(
42
+ repo_id="HuggingFaceH4/open_llm_leaderboard", token=H4_TOKEN
43
+ )
44
+
45
+ eval_queue, requested_models, eval_results = load_all_info_from_hub(QUEUE_REPO, RESULTS_REPO, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH)
46
+
47
+ if not IS_PUBLIC:
48
+ eval_queue_private, requested_models_private, eval_results_private = load_all_info_from_hub(PRIVATE_QUEUE_REPO, PRIVATE_RESULTS_REPO, EVAL_REQUESTS_PATH_PRIVATE, EVAL_RESULTS_PATH_PRIVATE)
49
+ else:
50
+ eval_queue_private, eval_results_private = None, None
51
+
52
+ COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
53
+ TYPES = [c.type for c in fields(AutoEvalColumn) if not c.hidden]
54
+ COLS_LITE = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
55
+ TYPES_LITE = [c.type for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
56
+
57
+ if not IS_PUBLIC:
58
+ COLS.insert(2, AutoEvalColumn.precision.name)
59
+ TYPES.insert(2, AutoEvalColumn.precision.type)
60
+
61
+ EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
62
+ EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
63
+
64
+ BENCHMARK_COLS = [c.name for c in [AutoEvalColumn.arc, AutoEvalColumn.hellaswag, AutoEvalColumn.mmlu, AutoEvalColumn.truthfulqa]]
65
+
66
+
67
+ def has_no_nan_values(df, columns):
68
+ return df[columns].notna().all(axis=1)
69
+
70
+
71
+ def has_nan_values(df, columns):
72
+ return df[columns].isna().any(axis=1)
73
+
74
+
75
+ def get_leaderboard_df():
76
+ if eval_results:
77
+ print("Pulling evaluation results for the leaderboard.")
78
+ eval_results.git_pull()
79
+ if eval_results_private:
80
+ print("Pulling evaluation results for the leaderboard.")
81
+ eval_results_private.git_pull()
82
+
83
+ all_data = get_eval_results_dicts(IS_PUBLIC)
84
+
85
+ if not IS_PUBLIC:
86
+ all_data.append(gpt4_values)
87
+ all_data.append(gpt35_values)
88
+
89
+ all_data.append(baseline)
90
+ apply_metadata(all_data) # Populate model type based on known hardcoded values in `metadata.py`
91
+
92
+ df = pd.DataFrame.from_records(all_data)
93
+ df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
94
+ df = df[COLS]
95
+
96
+ # filter out if any of the benchmarks have not been produced
97
+ df = df[has_no_nan_values(df, BENCHMARK_COLS)]
98
+ return df
99
+
100
+
101
+ def get_evaluation_queue_df():
102
+ # todo @saylortwift: replace the repo by the one you created for the eval queue
103
+ if eval_queue:
104
+ print("Pulling changes for the evaluation queue.")
105
+ eval_queue.git_pull()
106
+ if eval_queue_private:
107
+ print("Pulling changes for the evaluation queue.")
108
+ eval_queue_private.git_pull()
109
+
110
+ entries = [
111
+ entry
112
+ for entry in os.listdir(EVAL_REQUESTS_PATH)
113
+ if not entry.startswith(".")
114
+ ]
115
+ all_evals = []
116
+
117
+ for entry in entries:
118
+ if ".json" in entry:
119
+ file_path = os.path.join(EVAL_REQUESTS_PATH, entry)
120
+ with open(file_path) as fp:
121
+ data = json.load(fp)
122
+
123
+ data["# params"] = "unknown"
124
+ data["model"] = make_clickable_model(data["model"])
125
+ data["revision"] = data.get("revision", "main")
126
+
127
+ all_evals.append(data)
128
+ elif ".md" not in entry:
129
+ # this is a folder
130
+ sub_entries = [
131
+ e
132
+ for e in os.listdir(f"{EVAL_REQUESTS_PATH}/{entry}")
133
+ if not e.startswith(".")
134
+ ]
135
+ for sub_entry in sub_entries:
136
+ file_path = os.path.join(EVAL_REQUESTS_PATH, entry, sub_entry)
137
+ with open(file_path) as fp:
138
+ data = json.load(fp)
139
+
140
+ # data["# params"] = get_n_params(data["model"])
141
+ data["model"] = make_clickable_model(data["model"])
142
+ all_evals.append(data)
143
+
144
+ pending_list = [e for e in all_evals if e["status"] == "PENDING"]
145
+ running_list = [e for e in all_evals if e["status"] == "RUNNING"]
146
+ finished_list = [e for e in all_evals if e["status"].startswith("FINISHED")]
147
+ df_pending = pd.DataFrame.from_records(pending_list, columns=EVAL_COLS)
148
+ df_running = pd.DataFrame.from_records(running_list, columns=EVAL_COLS)
149
+ df_finished = pd.DataFrame.from_records(finished_list, columns=EVAL_COLS)
150
+ return df_finished[EVAL_COLS], df_running[EVAL_COLS], df_pending[EVAL_COLS]
151
+
152
+
153
+
154
+ original_df = get_leaderboard_df()
155
+ leaderboard_df = original_df.copy()
156
+ (
157
+ finished_eval_queue_df,
158
+ running_eval_queue_df,
159
+ pending_eval_queue_df,
160
+ ) = get_evaluation_queue_df()
161
+
162
+ def is_model_on_hub(model_name, revision) -> bool:
163
+ try:
164
+ AutoConfig.from_pretrained(model_name, revision=revision)
165
+ return True, None
166
+
167
+ except ValueError as e:
168
+ return False, "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."
169
+
170
+ except Exception as e:
171
+ print(f"Could not get the model config from the hub.: {e}")
172
+ return False, "was not found on hub!"
173
+
174
+
175
+ def add_new_eval(
176
+ model: str,
177
+ base_model: str,
178
+ revision: str,
179
+ precision: str,
180
+ private: bool,
181
+ weight_type: str,
182
+ ):
183
+ precision = precision.split(" ")[0]
184
+ current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
185
+
186
+ # check the model actually exists before adding the eval
187
+ if revision == "":
188
+ revision = "main"
189
+
190
+ if weight_type in ["Delta", "Adapter"]:
191
+ base_model_on_hub, error = is_model_on_hub(base_model, revision)
192
+ if not base_model_on_hub:
193
+ return styled_error(f'Base model "{base_model}" {error}')
194
+
195
+
196
+ if not weight_type == "Adapter":
197
+ model_on_hub, error = is_model_on_hub(model, revision)
198
+ if not model_on_hub:
199
+ return styled_error(f'Model "{model}" {error}')
200
+
201
+ print("adding new eval")
202
+
203
+ eval_entry = {
204
+ "model": model,
205
+ "base_model": base_model,
206
+ "revision": revision,
207
+ "private": private,
208
+ "precision": precision,
209
+ "weight_type": weight_type,
210
+ "status": "PENDING",
211
+ "submitted_time": current_time,
212
+ }
213
+
214
+ user_name = ""
215
+ model_path = model
216
+ if "/" in model:
217
+ user_name = model.split("/")[0]
218
+ model_path = model.split("/")[1]
219
+
220
+ OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
221
+ os.makedirs(OUT_DIR, exist_ok=True)
222
+ out_path = f"{OUT_DIR}/{model_path}_eval_request_{private}_{precision}_{weight_type}.json"
223
+
224
+ # Check for duplicate submission
225
+ if out_path.split("eval-queue/")[1].lower() in requested_models:
226
+ return styled_warning("This model has been already submitted.")
227
+
228
+ with open(out_path, "w") as f:
229
+ f.write(json.dumps(eval_entry))
230
+
231
+ api.upload_file(
232
+ path_or_fileobj=out_path,
233
+ path_in_repo=out_path.split("eval-queue/")[1],
234
+ repo_id=QUEUE_REPO,
235
+ token=H4_TOKEN,
236
+ repo_type="dataset",
237
+ commit_message=f"Add {model} to eval queue",
238
+ )
239
+
240
+ # remove the local file
241
+ os.remove(out_path)
242
+
243
+ return styled_message("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.")
244
+
245
+
246
+ def refresh():
247
+ leaderboard_df = get_leaderboard_df()
248
+ (
249
+ finished_eval_queue_df,
250
+ running_eval_queue_df,
251
+ pending_eval_queue_df,
252
+ ) = get_evaluation_queue_df()
253
+ return (
254
+ leaderboard_df,
255
+ finished_eval_queue_df,
256
+ running_eval_queue_df,
257
+ pending_eval_queue_df,
258
+ )
259
+
260
+
261
+ def search_table(df, query):
262
+ if AutoEvalColumn.model_type.name in df.columns:
263
+ filtered_df = df[
264
+ (df[AutoEvalColumn.dummy.name].str.contains(query, case=False))
265
+ | (df[AutoEvalColumn.model_type.name].str.contains(query, case=False))
266
+ ]
267
+ else:
268
+ filtered_df = df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
269
+ return filtered_df
270
+
271
+
272
+ def change_tab(query_param):
273
+ query_param = query_param.replace("'", '"')
274
+ query_param = json.loads(query_param)
275
+
276
+ if (
277
+ isinstance(query_param, dict)
278
+ and "tab" in query_param
279
+ and query_param["tab"] == "evaluation"
280
+ ):
281
+ return gr.Tabs.update(selected=1)
282
+ else:
283
+ return gr.Tabs.update(selected=0)
284
+
285
+
286
+ demo = gr.Blocks(css=custom_css)
287
+ with demo:
288
+ gr.HTML(TITLE)
289
+ gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
290
+ with gr.Row():
291
+ with gr.Box(elem_id="search-bar-table-box"):
292
+ search_bar = gr.Textbox(
293
+ placeholder="🔍 Search your model and press ENTER...",
294
+ show_label=False,
295
+ elem_id="search-bar",
296
+ )
297
+
298
+ with gr.Tabs(elem_classes="tab-buttons") as tabs:
299
+ with gr.TabItem("🏅 LLM Benchmark (lite)", elem_id="llm-benchmark-tab-table", id=0):
300
+ leaderboard_table_lite = gr.components.Dataframe(
301
+ value=leaderboard_df[COLS_LITE],
302
+ headers=COLS_LITE,
303
+ datatype=TYPES_LITE,
304
+ max_rows=None,
305
+ elem_id="leaderboard-table-lite",
306
+ )
307
+ # Dummy leaderboard for handling the case when the user uses backspace key
308
+ hidden_leaderboard_table_for_search_lite = gr.components.Dataframe(
309
+ value=original_df[COLS_LITE],
310
+ headers=COLS_LITE,
311
+ datatype=TYPES_LITE,
312
+ max_rows=None,
313
+ visible=False,
314
+ )
315
+ search_bar.submit(
316
+ search_table,
317
+ [hidden_leaderboard_table_for_search_lite, search_bar],
318
+ leaderboard_table_lite,
319
+ )
320
+
321
+ with gr.TabItem("📊 Extended view", elem_id="llm-benchmark-tab-table", id=1):
322
+ leaderboard_table = gr.components.Dataframe(
323
+ value=leaderboard_df,
324
+ headers=COLS,
325
+ datatype=TYPES,
326
+ max_rows=None,
327
+ elem_id="leaderboard-table",
328
+ )
329
+
330
+ # Dummy leaderboard for handling the case when the user uses backspace key
331
+ hidden_leaderboard_table_for_search = gr.components.Dataframe(
332
+ value=original_df,
333
+ headers=COLS,
334
+ datatype=TYPES,
335
+ max_rows=None,
336
+ visible=False,
337
+ )
338
+ search_bar.submit(
339
+ search_table,
340
+ [hidden_leaderboard_table_for_search, search_bar],
341
+ leaderboard_table,
342
+ )
343
+ with gr.TabItem("About", elem_id="llm-benchmark-tab-table", id=2):
344
+ gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
345
+
346
+ with gr.TabItem("✉️✨ Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
347
+ with gr.Column():
348
+ with gr.Row():
349
+ gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
350
+
351
+ with gr.Column():
352
+ with gr.Accordion("✅ Finished Evaluations", open=False):
353
+ with gr.Row():
354
+ finished_eval_table = gr.components.Dataframe(
355
+ value=finished_eval_queue_df,
356
+ headers=EVAL_COLS,
357
+ datatype=EVAL_TYPES,
358
+ max_rows=5,
359
+ )
360
+ with gr.Accordion("🔄 Running Evaluation Queue", open=False):
361
+ with gr.Row():
362
+ running_eval_table = gr.components.Dataframe(
363
+ value=running_eval_queue_df,
364
+ headers=EVAL_COLS,
365
+ datatype=EVAL_TYPES,
366
+ max_rows=5,
367
+ )
368
+
369
+ with gr.Accordion("⏳ Pending Evaluation Queue", open=False):
370
+ with gr.Row():
371
+ pending_eval_table = gr.components.Dataframe(
372
+ value=pending_eval_queue_df,
373
+ headers=EVAL_COLS,
374
+ datatype=EVAL_TYPES,
375
+ max_rows=5,
376
+ )
377
+ with gr.Row():
378
+ gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
379
+
380
+ with gr.Row():
381
+ with gr.Column():
382
+ model_name_textbox = gr.Textbox(label="Model name")
383
+ revision_name_textbox = gr.Textbox(
384
+ label="revision", placeholder="main"
385
+ )
386
+ private = gr.Checkbox(
387
+ False, label="Private", visible=not IS_PUBLIC
388
+ )
389
+
390
+ with gr.Column():
391
+ precision = gr.Dropdown(
392
+ choices=["float16", "bfloat16", "8bit (LLM.int8)", "4bit (QLoRA / FP4)"],
393
+ label="Precision",
394
+ multiselect=False,
395
+ value="float16",
396
+ max_choices=1,
397
+ interactive=True,
398
+ )
399
+ weight_type = gr.Dropdown(
400
+ choices=["Original", "Delta", "Adapter"],
401
+ label="Weights type",
402
+ multiselect=False,
403
+ value="Original",
404
+ max_choices=1,
405
+ interactive=True,
406
+ )
407
+ base_model_name_textbox = gr.Textbox(
408
+ label="Base model (for delta or adapter weights)"
409
+ )
410
+
411
+ submit_button = gr.Button("Submit Eval")
412
+ submission_result = gr.Markdown()
413
+ submit_button.click(
414
+ add_new_eval,
415
+ [
416
+ model_name_textbox,
417
+ base_model_name_textbox,
418
+ revision_name_textbox,
419
+ precision,
420
+ private,
421
+ weight_type,
422
+ ],
423
+ submission_result,
424
+ )
425
+
426
+ with gr.Row():
427
+ refresh_button = gr.Button("Refresh")
428
+ refresh_button.click(
429
+ refresh,
430
+ inputs=[],
431
+ outputs=[
432
+ leaderboard_table,
433
+ finished_eval_table,
434
+ running_eval_table,
435
+ pending_eval_table,
436
+ ],
437
+ )
438
+
439
+ with gr.Row():
440
+ with gr.Accordion("📙 Citation", open=False):
441
+ citation_button = gr.Textbox(
442
+ value=CITATION_BUTTON_TEXT,
443
+ label=CITATION_BUTTON_LABEL,
444
+ elem_id="citation-button",
445
+ ).style(show_copy_button=True)
446
+
447
+ dummy = gr.Textbox(visible=False)
448
+ demo.load(
449
+ change_tab,
450
+ dummy,
451
+ tabs,
452
+ _js=get_window_url_params,
453
+ )
454
+
455
+ scheduler = BackgroundScheduler()
456
+ scheduler.add_job(restart_space, "interval", seconds=3600)
457
+ scheduler.start()
458
+ demo.queue(concurrency_count=40).launch()
requirements.txt ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.1.0
2
+ aiohttp==3.8.4
3
+ aiosignal==1.3.1
4
+ altair==4.2.2
5
+ anyio==3.6.2
6
+ APScheduler==3.10.1
7
+ async-timeout==4.0.2
8
+ attrs==23.1.0
9
+ certifi==2022.12.7
10
+ charset-normalizer==3.1.0
11
+ click==8.1.3
12
+ contourpy==1.0.7
13
+ cycler==0.11.0
14
+ datasets==2.12.0
15
+ entrypoints==0.4
16
+ fastapi==0.95.1
17
+ ffmpy==0.3.0
18
+ filelock==3.11.0
19
+ fonttools==4.39.3
20
+ frozenlist==1.3.3
21
+ fsspec==2023.4.0
22
+ gradio==3.27.0
23
+ gradio_client==0.1.3
24
+ h11==0.14.0
25
+ httpcore==0.17.0
26
+ httpx==0.24.0
27
+ huggingface-hub==0.13.4
28
+ idna==3.4
29
+ Jinja2==3.1.2
30
+ jsonschema==4.17.3
31
+ kiwisolver==1.4.4
32
+ linkify-it-py==2.0.0
33
+ markdown-it-py==2.2.0
34
+ MarkupSafe==2.1.2
35
+ matplotlib==3.7.1
36
+ mdit-py-plugins==0.3.3
37
+ mdurl==0.1.2
38
+ multidict==6.0.4
39
+ numpy==1.24.2
40
+ orjson==3.8.10
41
+ packaging==23.1
42
+ pandas==2.0.0
43
+ Pillow==9.5.0
44
+ plotly==5.14.1
45
+ pyarrow==11.0.0
46
+ pydantic==1.10.7
47
+ pydub==0.25.1
48
+ pyparsing==3.0.9
49
+ pyrsistent==0.19.3
50
+ python-dateutil==2.8.2
51
+ python-multipart==0.0.6
52
+ pytz==2023.3
53
+ pytz-deprecation-shim==0.1.0.post0
54
+ PyYAML==6.0
55
+ requests==2.28.2
56
+ semantic-version==2.10.0
57
+ six==1.16.0
58
+ sniffio==1.3.0
59
+ starlette==0.26.1
60
+ toolz==0.12.0
61
+ tqdm==4.65.0
62
+ transformers==4.28.1
63
+ typing_extensions==4.5.0
64
+ tzdata==2023.3
65
+ tzlocal==4.3
66
+ uc-micro-py==1.0.1
67
+ urllib3==1.26.15
68
+ uvicorn==0.21.1
69
+ websockets==11.0.1
70
+ yarl==1.8.2
src/assets/css_html_js.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ custom_css = """
2
+ #changelog-text {
3
+ font-size: 16px !important;
4
+ }
5
+
6
+ #changelog-text h2 {
7
+ font-size: 18px !important;
8
+ }
9
+
10
+ .markdown-text {
11
+ font-size: 16px !important;
12
+ }
13
+
14
+ #models-to-add-text {
15
+ font-size: 18px !important;
16
+ }
17
+
18
+ #citation-button span {
19
+ font-size: 16px !important;
20
+ }
21
+
22
+ #citation-button textarea {
23
+ font-size: 16px !important;
24
+ }
25
+
26
+ #citation-button > label > button {
27
+ margin: 6px;
28
+ transform: scale(1.3);
29
+ }
30
+
31
+ #leaderboard-table {
32
+ margin-top: 15px
33
+ }
34
+
35
+ #leaderboard-table-lite {
36
+ margin-top: 15px
37
+ }
38
+
39
+ #search-bar-table-box > div:first-child {
40
+ background: none;
41
+ border: none;
42
+ }
43
+
44
+ #search-bar {
45
+ padding: 0px;
46
+ width: 30%;
47
+ }
48
+
49
+ /* Hides the final AutoEvalColumn */
50
+ #llm-benchmark-tab-table table td:last-child,
51
+ #llm-benchmark-tab-table table th:last-child {
52
+ display: none;
53
+ }
54
+
55
+ /* Limit the width of the first AutoEvalColumn so that names don't expand too much */
56
+ table td:first-child,
57
+ table th:first-child {
58
+ max-width: 400px;
59
+ overflow: auto;
60
+ white-space: nowrap;
61
+ }
62
+
63
+ .tab-buttons button {
64
+ font-size: 20px;
65
+ }
66
+
67
+ #scale-logo {
68
+ border-style: none !important;
69
+ box-shadow: none;
70
+ display: block;
71
+ margin-left: auto;
72
+ margin-right: auto;
73
+ max-width: 600px;
74
+ }
75
+
76
+ #scale-logo .download {
77
+ display: none;
78
+ }
79
+ """
80
+
81
+ get_window_url_params = """
82
+ function(url_params) {
83
+ const params = new URLSearchParams(window.location.search);
84
+ url_params = Object.fromEntries(params);
85
+ return url_params;
86
+ }
87
+ """
src/assets/hardcoded_evals.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from src.utils_display import AutoEvalColumn, model_hyperlink
2
+
3
+ gpt4_values = {
4
+ AutoEvalColumn.model.name: model_hyperlink("https://arxiv.org/abs/2303.08774", "gpt4"),
5
+ AutoEvalColumn.revision.name: "tech report",
6
+ AutoEvalColumn.precision.name: None,
7
+ AutoEvalColumn.average.name: 84.3,
8
+ AutoEvalColumn.arc.name: 96.3,
9
+ AutoEvalColumn.hellaswag.name: 95.3,
10
+ AutoEvalColumn.mmlu.name: 86.4,
11
+ AutoEvalColumn.truthfulqa.name: 59.0,
12
+ AutoEvalColumn.dummy.name: "GPT-4",
13
+ }
14
+
15
+ gpt35_values = {
16
+ AutoEvalColumn.model.name: model_hyperlink("https://arxiv.org/abs/2303.08774", "gpt3.5"),
17
+ AutoEvalColumn.revision.name: "tech report",
18
+ AutoEvalColumn.precision.name: None,
19
+ AutoEvalColumn.average.name: 71.9,
20
+ AutoEvalColumn.arc.name: 85.2,
21
+ AutoEvalColumn.hellaswag.name: 85.5,
22
+ AutoEvalColumn.mmlu.name: 70.0,
23
+ AutoEvalColumn.truthfulqa.name: 47.0,
24
+ AutoEvalColumn.dummy.name: "GPT-3.5",
25
+ }
26
+
27
+ baseline = {
28
+ AutoEvalColumn.model.name: "<p>Baseline</p>",
29
+ AutoEvalColumn.revision.name: "N/A",
30
+ AutoEvalColumn.precision.name: None,
31
+ AutoEvalColumn.average.name: 25.0,
32
+ AutoEvalColumn.arc.name: 25.0,
33
+ AutoEvalColumn.hellaswag.name: 25.0,
34
+ AutoEvalColumn.mmlu.name: 25.0,
35
+ AutoEvalColumn.truthfulqa.name: 25.0,
36
+ AutoEvalColumn.dummy.name: "baseline",
37
+ }
38
+
src/assets/scale-hf-logo.png ADDED

Git LFS Details

  • SHA256: 11a263a1abe4c7c9cf022cbe052dc567dcea164bdfbc111299aae3270e992934
  • Pointer size: 132 Bytes
  • Size of remote file: 1.88 MB
src/assets/text_content.py ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CHANGELOG_TEXT = f"""
2
+ ## [2023-06-19]
3
+ - Added model type column
4
+ - Hid revision and 8bit columns since all models are the same atm
5
+
6
+ ## [2023-06-16]
7
+ - Refactored code base
8
+ - Added new columns: number of parameters, hub likes, license
9
+
10
+ ## [2023-06-13]
11
+ - Adjust description for TruthfulQA
12
+
13
+ ## [2023-06-12]
14
+ - Add Human & GPT-4 Evaluations
15
+
16
+ ## [2023-06-05]
17
+ - Increase concurrent thread count to 40
18
+ - Search models on ENTER
19
+
20
+ ## [2023-06-02]
21
+ - Add a typeahead search bar
22
+ - Use webhooks to automatically spawn a new Space when someone opens a PR
23
+ - Start recording `submitted_time` for eval requests
24
+ - Limit AutoEvalColumn max-width
25
+
26
+ ## [2023-05-30]
27
+ - Add a citation button
28
+ - Simplify Gradio layout
29
+
30
+ ## [2023-05-29]
31
+ - Auto-restart every hour for the latest results
32
+ - Sync with the internal version (minor style changes)
33
+
34
+ ## [2023-05-24]
35
+ - Add a baseline that has 25.0 for all values
36
+ - Add CHANGELOG
37
+
38
+ ## [2023-05-23]
39
+ - Fix a CSS issue that made the leaderboard hard to read in dark mode
40
+
41
+ ## [2023-05-22]
42
+ - Display a success/error message after submitting evaluation requests
43
+ - Reject duplicate submission
44
+ - Do not display results that have incomplete results
45
+ - Display different queues for jobs that are RUNNING, PENDING, FINISHED status
46
+
47
+ ## [2023-05-15]
48
+ - Fix a typo: from "TruthQA" to "QA"
49
+
50
+ ## [2023-05-10]
51
+ - Fix a bug that prevented auto-refresh
52
+
53
+ ## [2023-05-10]
54
+ - Release the leaderboard to public
55
+ """
56
+
57
+ TITLE = """<h1 align="center" id="space-title">🤗 Open LLM Leaderboard</h1>"""
58
+
59
+ INTRODUCTION_TEXT = f"""
60
+ 📐 The 🤗 Open LLM Leaderboard aims to track, rank and evaluate LLMs and chatbots as they are released.
61
+
62
+ 🤗 Anyone from the community can submit a model for automated evaluation on the 🤗 GPU cluster, as long as it is a 🤗 Transformers model with weights on the Hub. We also support evaluation of models with delta-weights for non-commercial licensed models, such as the original LLaMa release.
63
+
64
+ Other cool benchmarks for LLMs are developped at HuggingFace, go check them out: 🙋🤖 [human and GPT4 evals](https://huggingface.co/spaces/HuggingFaceH4/human_eval_llm_leaderboard), 🖥️ [performance benchmarks](https://huggingface.co/spaces/optimum/llm-perf-leaderboard)
65
+ """
66
+
67
+ LLM_BENCHMARKS_TEXT = f"""
68
+ # Context
69
+ 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.
70
+
71
+ 📈 We evaluate models on 4 key benchmarks from 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.
72
+
73
+ - <a href="https://arxiv.org/abs/1803.05457" target="_blank"> AI2 Reasoning Challenge </a> (25-shot) - a set of grade-school science questions.
74
+ - <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.
75
+ - <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.
76
+ - <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 in the Harness is actually a minima a 6-shots task, as it is prepended by 6 examples systematically, even when launched using 0 for the number of few-shot examples.
77
+
78
+ We chose these benchmarks as they test a variety of reasoning and general knowledge across a wide variety of fields in 0-shot and few-shot settings.
79
+
80
+ # Some good practices before submitting a model
81
+
82
+ ### 1) Make sure you can load your model and tokenizer using AutoClasses:
83
+ ```python
84
+ from transformers import AutoConfig, AutoModel, AutoTokenizer
85
+ config = AutoConfig.from_pretrained("your model name", revision=revision)
86
+ model = AutoModel.from_pretrained("your model name", revision=revision)
87
+ tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
88
+ ```
89
+ If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
90
+
91
+ Note: make sure your model is public!
92
+ 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!
93
+
94
+ ### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
95
+ 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 weights of your model to the `Extended Viewer`!
96
+
97
+ ### 3) Make sure your model has an open license!
98
+ This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
99
+
100
+ ### 4) Fill up your model card
101
+ When we add extra information about models to the leaderboard, it will be automatically taken from the model card
102
+
103
+ # Reproducibility and details
104
+
105
+ ### Details and logs
106
+ You can find:
107
+ - detailed numerical results in the `results` Hugging Face dataset: https://huggingface.co/datasets/open-llm-leaderboard/results
108
+ - details on the input/outputs for the models in the `details` Hugging Face dataset: https://huggingface.co/datasets/open-llm-leaderboard/details
109
+ - community queries and running status in the `requests` Hugging Face dataset: https://huggingface.co/datasets/open-llm-leaderboard/requests
110
+
111
+ ### Reproducibility
112
+ To reproduce our results, here is the commands you can run, using [this version](https://github.com/EleutherAI/lm-evaluation-harness/tree/b281b0921b636bc36ad05c0b0b0763bd6dd43463) of the Eleuther AI Harness:
113
+ `python main.py --model=hf-causal --model_args="pretrained=<your_model>,use_accelerate=True,revision=<your_model_revision>"`
114
+ ` --tasks=<task_list> --num_fewshot=<n_few_shot> --batch_size=2 --output_path=<output_path>`
115
+
116
+ The total batch size we get for models which fit on one A100 node is 16 (8 GPUs * 2). If you don't use parallelism, adapt your batch size to fit.
117
+ *You can expect results to vary slightly for different batch sizes because of padding.*
118
+
119
+ The tasks and few shots parameters are:
120
+ - ARC: 25-shot, *arc-challenge* (`acc_norm`)
121
+ - HellaSwag: 10-shot, *hellaswag* (`acc_norm`)
122
+ - TruthfulQA: 0-shot, *truthfulqa-mc* (`mc2`)
123
+ - 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* (`acc` of `all`)
124
+
125
+ ### Quantization
126
+ To get more information about quantization, see:
127
+ - 8 bits: [blog post](https://huggingface.co/blog/hf-bitsandbytes-integration), [paper](https://arxiv.org/abs/2208.07339)
128
+ - 4 bits: [blog post](https://huggingface.co/blog/4bit-transformers-bitsandbytes), [paper](https://arxiv.org/abs/2305.14314)
129
+
130
+ # In case of model failure
131
+ If your model is displayed in the `FAILED` category, its execution stopped.
132
+ Make sure you have followed the above steps first.
133
+ 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).
134
+
135
+ """
136
+
137
+ EVALUATION_QUEUE_TEXT = f"""
138
+ # Evaluation Queue for the 🤗 Open LLM Leaderboard
139
+ These models will be automatically evaluated on the 🤗 cluster.
140
+ """
141
+
142
+ CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
143
+ CITATION_BUTTON_TEXT = r"""@misc{open-llm-leaderboard,
144
+ author = {Edward Beeching, Clémentine Fourrier, Nathan Habib, Sheon Han, Nathan Lambert, Nazneen Rajani, Omar Sanseviero, Lewis Tunstall, Thomas Wolf},
145
+ title = {Open LLM Leaderboard},
146
+ year = {2023},
147
+ publisher = {Hugging Face},
148
+ howpublished = "\url{https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard}"
149
+
150
+ }
151
+ @software{eval-harness,
152
+ author = {Gao, Leo and
153
+ Tow, Jonathan and
154
+ Biderman, Stella and
155
+ Black, Sid and
156
+ DiPofi, Anthony and
157
+ Foster, Charles and
158
+ Golding, Laurence and
159
+ Hsu, Jeffrey and
160
+ McDonell, Kyle and
161
+ Muennighoff, Niklas and
162
+ Phang, Jason and
163
+ Reynolds, Laria and
164
+ Tang, Eric and
165
+ Thite, Anish and
166
+ Wang, Ben and
167
+ Wang, Kevin and
168
+ Zou, Andy},
169
+ title = {A framework for few-shot language model evaluation},
170
+ month = sep,
171
+ year = 2021,
172
+ publisher = {Zenodo},
173
+ version = {v0.0.1},
174
+ doi = {10.5281/zenodo.5371628},
175
+ url = {https://doi.org/10.5281/zenodo.5371628}
176
+ }
177
+ @misc{clark2018think,
178
+ title={Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge},
179
+ author={Peter Clark and Isaac Cowhey and Oren Etzioni and Tushar Khot and Ashish Sabharwal and Carissa Schoenick and Oyvind Tafjord},
180
+ year={2018},
181
+ eprint={1803.05457},
182
+ archivePrefix={arXiv},
183
+ primaryClass={cs.AI}
184
+ }
185
+ @misc{zellers2019hellaswag,
186
+ title={HellaSwag: Can a Machine Really Finish Your Sentence?},
187
+ author={Rowan Zellers and Ari Holtzman and Yonatan Bisk and Ali Farhadi and Yejin Choi},
188
+ year={2019},
189
+ eprint={1905.07830},
190
+ archivePrefix={arXiv},
191
+ primaryClass={cs.CL}
192
+ }
193
+ @misc{hendrycks2021measuring,
194
+ title={Measuring Massive Multitask Language Understanding},
195
+ author={Dan Hendrycks and Collin Burns and Steven Basart and Andy Zou and Mantas Mazeika and Dawn Song and Jacob Steinhardt},
196
+ year={2021},
197
+ eprint={2009.03300},
198
+ archivePrefix={arXiv},
199
+ primaryClass={cs.CY}
200
+ }
201
+ @misc{lin2022truthfulqa,
202
+ title={TruthfulQA: Measuring How Models Mimic Human Falsehoods},
203
+ author={Stephanie Lin and Jacob Hilton and Owain Evans},
204
+ year={2022},
205
+ eprint={2109.07958},
206
+ archivePrefix={arXiv},
207
+ primaryClass={cs.CL}
208
+ }"""
src/auto_leaderboard/get_model_metadata.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import os
3
+ from typing import List
4
+
5
+ from src.utils_display import AutoEvalColumn
6
+ from src.auto_leaderboard.model_metadata_type import get_model_type
7
+
8
+ from huggingface_hub import HfApi
9
+ import huggingface_hub
10
+ api = HfApi(token=os.environ.get("H4_TOKEN", None))
11
+
12
+
13
+ def get_model_infos_from_hub(leaderboard_data: List[dict]):
14
+ for model_data in leaderboard_data:
15
+ model_name = model_data["model_name_for_query"]
16
+ try:
17
+ model_info = api.model_info(model_name)
18
+ except huggingface_hub.utils._errors.RepositoryNotFoundError:
19
+ print("Repo not found!", model_name)
20
+ model_data[AutoEvalColumn.license.name] = None
21
+ model_data[AutoEvalColumn.likes.name] = None
22
+ model_data[AutoEvalColumn.params.name] = get_model_size(model_name, None)
23
+ continue
24
+
25
+ model_data[AutoEvalColumn.license.name] = get_model_license(model_info)
26
+ model_data[AutoEvalColumn.likes.name] = get_model_likes(model_info)
27
+ model_data[AutoEvalColumn.params.name] = get_model_size(model_name, model_info)
28
+
29
+
30
+ def get_model_license(model_info):
31
+ try:
32
+ return model_info.cardData["license"]
33
+ except Exception:
34
+ return None
35
+
36
+ def get_model_likes(model_info):
37
+ return model_info.likes
38
+
39
+ size_pattern = re.compile(r"(\d\.)?\d+(b|m)")
40
+
41
+ def get_model_size(model_name, model_info):
42
+ # In billions
43
+ try:
44
+ return round(model_info.safetensors["total"] / 1e9, 3)
45
+ except AttributeError:
46
+ try:
47
+ size_match = re.search(size_pattern, model_name.lower())
48
+ size = size_match.group(0)
49
+ return round(float(size[:-1]) if size[-1] == "b" else float(size[:-1]) / 1e3, 3)
50
+ except AttributeError:
51
+ return None
52
+
53
+
54
+ def apply_metadata(leaderboard_data: List[dict]):
55
+ get_model_type(leaderboard_data)
56
+ get_model_infos_from_hub(leaderboard_data)
src/auto_leaderboard/load_results.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+
3
+ import glob
4
+ import json
5
+ import os
6
+ from typing import Dict, List, Tuple
7
+
8
+ from src.utils_display import AutoEvalColumn, make_clickable_model
9
+ import numpy as np
10
+
11
+ METRICS = ["acc_norm", "acc_norm", "acc", "mc2"]
12
+ BENCHMARKS = ["arc:challenge", "hellaswag", "hendrycksTest", "truthfulqa:mc"]
13
+ BENCH_TO_NAME = {
14
+ "arc:challenge": AutoEvalColumn.arc.name,
15
+ "hellaswag": AutoEvalColumn.hellaswag.name,
16
+ "hendrycksTest": AutoEvalColumn.mmlu.name,
17
+ "truthfulqa:mc": AutoEvalColumn.truthfulqa.name,
18
+ }
19
+
20
+
21
+ @dataclass
22
+ class EvalResult:
23
+ eval_name: str
24
+ org: str
25
+ model: str
26
+ revision: str
27
+ results: dict
28
+ precision: str = "16bit"
29
+
30
+ def to_dict(self):
31
+ if self.org is not None:
32
+ base_model = f"{self.org}/{self.model}"
33
+ else:
34
+ base_model = f"{self.model}"
35
+ data_dict = {}
36
+
37
+ data_dict["eval_name"] = self.eval_name # not a column, just a save name
38
+ data_dict[AutoEvalColumn.precision.name] = self.precision
39
+ data_dict[AutoEvalColumn.model.name] = make_clickable_model(base_model)
40
+ data_dict[AutoEvalColumn.dummy.name] = base_model
41
+ data_dict[AutoEvalColumn.revision.name] = self.revision
42
+ data_dict[AutoEvalColumn.average.name] = round(
43
+ sum([v for k, v in self.results.items()]) / 4.0, 1
44
+ )
45
+
46
+ for benchmark in BENCHMARKS:
47
+ if benchmark not in self.results.keys():
48
+ self.results[benchmark] = None
49
+
50
+ for k, v in BENCH_TO_NAME.items():
51
+ data_dict[v] = self.results[k]
52
+
53
+ return data_dict
54
+
55
+
56
+ def parse_eval_result(json_filepath: str) -> Tuple[str, list[dict]]:
57
+ with open(json_filepath) as fp:
58
+ data = json.load(fp)
59
+
60
+
61
+ for mmlu_k in ["harness|hendrycksTest-abstract_algebra|5", "hendrycksTest-abstract_algebra"]:
62
+ if mmlu_k in data["versions"] and data["versions"][mmlu_k] == 0:
63
+ return None, [] # we skip models with the wrong version
64
+
65
+ try:
66
+ config = data["config"]
67
+ except KeyError:
68
+ config = data["config_general"]
69
+ model = config.get("model_name", None)
70
+ if model is None:
71
+ model = config.get("model_args", None)
72
+
73
+ model_sha = config.get("model_sha", "")
74
+ eval_sha = config.get("lighteval_sha", "")
75
+ model_split = model.split("/", 1)
76
+
77
+ model = model_split[-1]
78
+
79
+ if len(model_split) == 1:
80
+ org = None
81
+ model = model_split[0]
82
+ result_key = f"{model}_{model_sha}_{eval_sha}"
83
+ else:
84
+ org = model_split[0]
85
+ model = model_split[1]
86
+ result_key = f"{org}_{model}_{model_sha}_{eval_sha}"
87
+
88
+ eval_results = []
89
+ for benchmark, metric in zip(BENCHMARKS, METRICS):
90
+ accs = np.array([v[metric] for k, v in data["results"].items() if benchmark in k])
91
+ if accs.size == 0:
92
+ continue
93
+ mean_acc = round(np.mean(accs) * 100.0, 1)
94
+ eval_results.append(EvalResult(
95
+ result_key, org, model, model_sha, {benchmark: mean_acc}
96
+ ))
97
+
98
+ return result_key, eval_results
99
+
100
+
101
+ def get_eval_results(is_public) -> List[EvalResult]:
102
+ json_filepaths = glob.glob(
103
+ "eval-results/**/results*.json", recursive=True
104
+ )
105
+ if not is_public:
106
+ json_filepaths += glob.glob(
107
+ "private-eval-results/**/results*.json", recursive=True
108
+ )
109
+
110
+ eval_results = {}
111
+
112
+ for json_filepath in json_filepaths:
113
+ result_key, results = parse_eval_result(json_filepath)
114
+ for eval_result in results:
115
+ if result_key in eval_results.keys():
116
+ eval_results[result_key].results.update(eval_result.results)
117
+ else:
118
+ eval_results[result_key] = eval_result
119
+
120
+ eval_results = [v for v in eval_results.values()]
121
+
122
+ return eval_results
123
+
124
+
125
+ def get_eval_results_dicts(is_public=True) -> List[Dict]:
126
+ eval_results = get_eval_results(is_public)
127
+
128
+ return [e.to_dict() for e in eval_results]
src/auto_leaderboard/model_metadata_type.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from enum import Enum
2
+ from typing import Dict, List
3
+
4
+ class ModelType(Enum):
5
+ PT = "pretrained"
6
+ SFT = "finetuned"
7
+ RL = "with RL"
8
+
9
+
10
+ TYPE_METADATA: Dict[str, ModelType] = {
11
+ "aisquared/dlite-v1-355m": ModelType.SFT,
12
+ "aisquared/dlite-v2-774m": ModelType.SFT,
13
+ "aisquared/dlite-v2-1_5b": ModelType.SFT,
14
+ "TheBloke/wizardLM-7B-HF": ModelType.SFT,
15
+ "TheBloke/dromedary-65b-lora-HF": ModelType.SFT,
16
+ "TheBloke/vicuna-13B-1.1-HF": ModelType.SFT,
17
+ "TheBloke/Wizard-Vicuna-13B-Uncensored-HF": ModelType.SFT,
18
+ "wordcab/llama-natural-instructions-13b": ModelType.SFT,
19
+ "JosephusCheung/Guanaco": ModelType.SFT,
20
+ "AlekseyKorshuk/vicuna-7b": ModelType.SFT,
21
+ "AlekseyKorshuk/chatml-pyg-v1": ModelType.SFT,
22
+ "concedo/OPT-19M-ChatSalad": ModelType.SFT,
23
+ "digitous/Javalion-R": ModelType.SFT,
24
+ "digitous/Alpacino30b": ModelType.SFT,
25
+ "digitous/Javelin-GPTJ": ModelType.SFT,
26
+ "anton-l/gpt-j-tiny-random": ModelType.SFT,
27
+ "IDEA-CCNL/Ziya-LLaMA-13B-Pretrain-v1": ModelType.SFT,
28
+ "gpt2-medium": ModelType.PT,
29
+ "PygmalionAI/pygmalion-6b": ModelType.SFT,
30
+ "medalpaca/medalpaca-7b": ModelType.SFT,
31
+ "medalpaca/medalpaca-13b": ModelType.SFT,
32
+ "chavinlo/alpaca-13b": ModelType.SFT,
33
+ "chavinlo/alpaca-native": ModelType.SFT,
34
+ "chavinlo/gpt4-x-alpaca": ModelType.SFT,
35
+ "hakurei/lotus-12B": ModelType.SFT,
36
+ "amazon/LightGPT": ModelType.SFT,
37
+ "shibing624/chinese-llama-plus-13b-hf": ModelType.SFT,
38
+ "mosaicml/mpt-7b": ModelType.PT,
39
+ "PSanni/Deer-3b": ModelType.SFT,
40
+ "bigscience/bloom-1b1": ModelType.PT,
41
+ "MetaIX/GPT4-X-Alpasta-30b": ModelType.SFT,
42
+ "EleutherAI/gpt-neox-20b": ModelType.PT,
43
+ "EleutherAI/gpt-j-6b": ModelType.PT,
44
+ "roneneldan/TinyStories-28M": ModelType.SFT,
45
+ "lmsys/vicuna-13b-delta-v1.1": ModelType.SFT,
46
+ "lmsys/vicuna-7b-delta-v1.1": ModelType.SFT,
47
+ "abhiramtirumala/DialoGPT-sarcastic-medium": ModelType.SFT,
48
+ "pillowtalks-ai/delta13b": ModelType.SFT,
49
+ "bigcode/starcoderplus": ModelType.SFT,
50
+ "microsoft/DialoGPT-large": ModelType.SFT,
51
+ "microsoft/CodeGPT-small-py": ModelType.SFT,
52
+ "Pirr/pythia-13b-deduped-green_devil": ModelType.SFT,
53
+ "Aeala/GPT4-x-AlpacaDente2-30b": ModelType.SFT,
54
+ "Aeala/VicUnlocked-alpaca-30b": ModelType.SFT,
55
+ "dvruette/llama-13b-pretrained-sft-epoch-2": ModelType.SFT,
56
+ "dvruette/oasst-gpt-neox-20b-1000-steps": ModelType.SFT,
57
+ "openlm-research/open_llama_3b_350bt_preview": ModelType.PT,
58
+ "openlm-research/open_llama_7b_700bt_preview": ModelType.PT,
59
+ "openlm-research/open_llama_7b": ModelType.PT,
60
+ "openlm-research/open_llama_3b": ModelType.PT,
61
+ "openlm-research/open_llama_7b_400bt_preview": ModelType.PT,
62
+ "PocketDoc/Dans-PileOfSets-Mk1-llama-13b-merged": ModelType.SFT,
63
+ "GeorgiaTechResearchInstitute/galactica-6.7b-evol-instruct-70k": ModelType.SFT,
64
+ "databricks/dolly-v2-7b": ModelType.SFT,
65
+ "databricks/dolly-v2-3b": ModelType.SFT,
66
+ "databricks/dolly-v2-12b": ModelType.SFT,
67
+ "pinkmanlove/llama-65b-hf": ModelType.SFT,
68
+ "Rachneet/gpt2-xl-alpaca": ModelType.SFT,
69
+ "Locutusque/gpt2-conversational-or-qa": ModelType.SFT,
70
+ "NbAiLab/nb-gpt-j-6B-alpaca": ModelType.SFT,
71
+ "Fredithefish/ScarletPajama-3B-HF": ModelType.SFT,
72
+ "eachadea/vicuna-7b-1.1": ModelType.SFT,
73
+ "eachadea/vicuna-13b": ModelType.SFT,
74
+ "openaccess-ai-collective/wizard-mega-13b": ModelType.SFT,
75
+ "openaccess-ai-collective/manticore-13b": ModelType.SFT,
76
+ "openaccess-ai-collective/manticore-30b-chat-pyg-alpha": ModelType.SFT,
77
+ "openaccess-ai-collective/minotaur-13b": ModelType.SFT,
78
+ "lamini/instruct-tuned-3b": ModelType.SFT,
79
+ "pythainlp/wangchanglm-7.5B-sft-enth": ModelType.SFT,
80
+ "pythainlp/wangchanglm-7.5B-sft-en-sharded": ModelType.SFT,
81
+ "stabilityai/stablelm-tuned-alpha-7b": ModelType.SFT,
82
+ "CalderaAI/30B-Lazarus": ModelType.SFT,
83
+ "KoboldAI/OPT-13B-Nerybus-Mix": ModelType.SFT,
84
+ "distilgpt2": ModelType.PT,
85
+ "wahaha1987/llama_7b_sharegpt94k_fastchat": ModelType.SFT,
86
+ "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5": ModelType.SFT,
87
+ "junelee/wizard-vicuna-13b": ModelType.SFT,
88
+ "BreadAi/StoryPy": ModelType.SFT,
89
+ "togethercomputer/RedPajama-INCITE-Base-3B-v1": ModelType.PT,
90
+ "togethercomputer/RedPajama-INCITE-Base-7B-v0.1": ModelType.PT,
91
+ "Writer/camel-5b-hf": ModelType.SFT,
92
+ "Writer/palmyra-base": ModelType.PT,
93
+ "MBZUAI/lamini-neo-125m": ModelType.SFT,
94
+ "TehVenom/DiffMerge_Pygmalion_Main-onto-V8P4": ModelType.SFT,
95
+ "vicgalle/gpt2-alpaca-gpt4": ModelType.SFT,
96
+ "facebook/opt-350m": ModelType.PT,
97
+ "facebook/opt-125m": ModelType.PT,
98
+ "facebook/opt-13b": ModelType.PT,
99
+ "facebook/opt-1.3b": ModelType.PT,
100
+ "facebook/opt-66b": ModelType.PT,
101
+ "facebook/galactica-120b": ModelType.PT,
102
+ "Abe13/jgpt2-v1": ModelType.SFT,
103
+ "gpt2-xl": ModelType.PT,
104
+ "HuggingFaceH4/stable-vicuna-13b-2904": ModelType.RL,
105
+ "HuggingFaceH4/llama-7b-ift-alpaca": ModelType.SFT,
106
+ "HuggingFaceH4/starchat-alpha": ModelType.SFT,
107
+ "HuggingFaceH4/starchat-beta": ModelType.SFT,
108
+ "ausboss/Llama30B-SuperHOT": ModelType.SFT,
109
+ "ausboss/llama-13b-supercot": ModelType.SFT,
110
+ "ausboss/llama-30b-supercot": ModelType.SFT,
111
+ "Neko-Institute-of-Science/metharme-7b": ModelType.SFT,
112
+ "SebastianSchramm/Cerebras-GPT-111M-instruction": ModelType.SFT,
113
+ "victor123/WizardLM-13B-1.0": ModelType.SFT,
114
+ "AlpinDale/pygmalion-instruct": ModelType.SFT,
115
+ "tiiuae/falcon-7b-instruct": ModelType.SFT,
116
+ "tiiuae/falcon-40b-instruct": ModelType.SFT,
117
+ "tiiuae/falcon-40b": ModelType.PT,
118
+ "tiiuae/falcon-7b": ModelType.PT,
119
+ "cyl/awsome-llama": ModelType.SFT,
120
+ "xzuyn/Alpacino-SuperCOT-13B": ModelType.SFT,
121
+ "xzuyn/MedicWizard-7B": ModelType.SFT,
122
+ "beomi/KoAlpaca-Polyglot-5.8B": ModelType.SFT,
123
+ "chainyo/alpaca-lora-7b": ModelType.SFT,
124
+ "Salesforce/codegen-16B-nl": ModelType.PT,
125
+ "Salesforce/codegen-16B-multi": ModelType.SFT,
126
+ "ai-forever/rugpt3large_based_on_gpt2": ModelType.SFT,
127
+ "gpt2-large": ModelType.PT,
128
+ "huggingface/llama-13b": ModelType.PT,
129
+ "huggingface/llama-7b": ModelType.PT,
130
+ "huggingface/llama-65b": ModelType.PT,
131
+ "huggingface/llama-30b": ModelType.PT,
132
+ "jondurbin/airoboros-7b": ModelType.SFT,
133
+ "jondurbin/airoboros-13b": ModelType.SFT,
134
+ "cerebras/Cerebras-GPT-1.3B": ModelType.PT,
135
+ "cerebras/Cerebras-GPT-111M": ModelType.PT,
136
+ "NousResearch/Nous-Hermes-13b": ModelType.SFT,
137
+ "project-baize/baize-v2-7b": ModelType.SFT,
138
+ "project-baize/baize-v2-13b": ModelType.SFT,
139
+ "LLMs/AlpacaGPT4-7B-elina": ModelType.SFT,
140
+ "LLMs/Vicuna-EvolInstruct-13B": ModelType.SFT,
141
+ "huggingtweets/jerma985": ModelType.SFT,
142
+ "huggyllama/llama-65b": ModelType.PT,
143
+ "WizardLM/WizardLM-13B-1.0": ModelType.SFT,
144
+ "gpt2": ModelType.PT,
145
+ "alessandropalla/instruct_gpt2": ModelType.SFT,
146
+ "MayaPH/FinOPT-Lincoln": ModelType.SFT,
147
+ "MayaPH/FinOPT-Franklin": ModelType.SFT,
148
+ "timdettmers/guanaco-33b-merged": ModelType.SFT,
149
+ "timdettmers/guanaco-65b-merged": ModelType.SFT,
150
+ "elinas/llama-30b-hf-transformers-4.29": ModelType.SFT,
151
+ "elinas/chronos-33b": ModelType.SFT,
152
+ "nmitchko/medguanaco-65b-GPTQ": ModelType.SFT,
153
+ "xhyi/PT_GPTNEO350_ATG": ModelType.SFT,
154
+ "h2oai/h2ogpt-oasst1-512-20b": ModelType.SFT,
155
+ "h2oai/h2ogpt-gm-oasst1-en-1024-12b": ModelType.SFT,
156
+ "nomic-ai/gpt4all-13b-snoozy": ModelType.SFT,
157
+ "nomic-ai/gpt4all-j": ModelType.SFT,
158
+ }
159
+
160
+
161
+ def get_model_type(leaderboard_data: List[dict]):
162
+ for model_data in leaderboard_data:
163
+ model_data["Type"] = TYPE_METADATA.get(model_data["model_name_for_query"], "N/A")
164
+ if model_data["Type"] == "N/A":
165
+ if any([i in model_data["model_name_for_query"] for i in ["finetuned", "-ft-"]]):
166
+ model_data["Type"] = ModelType.SFT
167
+ elif any([i in model_data["model_name_for_query"] for i in ["pretrained"]]):
168
+ model_data["Type"] = ModelType.PT
169
+ elif any([i in model_data["model_name_for_query"] for i in ["-rl-", "-rlhf-"]]):
170
+ model_data["Type"] = ModelType.RL
171
+
172
+
src/init.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import Repository
3
+
4
+ H4_TOKEN = os.environ.get("H4_TOKEN", None)
5
+
6
+
7
+ def get_all_requested_models(requested_models_dir):
8
+ depth = 1
9
+ file_names = []
10
+
11
+ for root, dirs, files in os.walk(requested_models_dir):
12
+ current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
13
+ if current_depth == depth:
14
+ file_names.extend([os.path.join(root, file) for file in files])
15
+
16
+ return set([file_name.lower().split("eval-queue/")[1] for file_name in file_names])
17
+
18
+ def load_all_info_from_hub(QUEUE_REPO, RESULTS_REPO, QUEUE_PATH, RESULTS_PATH):
19
+ eval_queue_repo = None
20
+ eval_results_repo = None
21
+ requested_models = None
22
+
23
+ if H4_TOKEN:
24
+ print("Pulling evaluation requests and results.")
25
+
26
+ eval_queue_repo = Repository(
27
+ local_dir=QUEUE_PATH,
28
+ clone_from=QUEUE_REPO,
29
+ use_auth_token=H4_TOKEN,
30
+ repo_type="dataset",
31
+ )
32
+ eval_queue_repo.git_pull()
33
+
34
+ eval_results_repo = Repository(
35
+ local_dir=RESULTS_PATH,
36
+ clone_from=RESULTS_REPO,
37
+ use_auth_token=H4_TOKEN,
38
+ repo_type="dataset",
39
+ )
40
+ eval_results_repo.git_pull()
41
+
42
+ requested_models = get_all_requested_models("eval-queue")
43
+ else:
44
+ print("No HuggingFace token provided. Skipping evaluation requests and results.")
45
+
46
+ return eval_queue_repo, requested_models, eval_results_repo
47
+
48
+
49
+ #def load_results(model, benchmark, metric):
50
+ # file_path = os.path.join("autoevals", model, f"{model}-eval_{benchmark}.json")
51
+ # if not os.path.exists(file_path):
52
+ # return 0.0, None
53
+
54
+ # with open(file_path) as fp:
55
+ # data = json.load(fp)
56
+ # accs = np.array([v[metric] for k, v in data["results"].items()])
57
+ # mean_acc = np.mean(accs)
58
+ # return mean_acc, data["config"]["model_args"]
src/utils_display.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+
3
+ # These classes are for user facing column names, to avoid having to change them
4
+ # all around the code when a modif is needed
5
+ @dataclass
6
+ class ColumnContent:
7
+ name: str
8
+ type: str
9
+ displayed_by_default: bool
10
+ hidden: bool = False
11
+
12
+ def fields(raw_class):
13
+ return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
14
+
15
+ @dataclass(frozen=True)
16
+ class AutoEvalColumn: # Auto evals column
17
+ model = ColumnContent("Model", "markdown", True)
18
+ average = ColumnContent("Average ⬆️", "number", True)
19
+ arc = ColumnContent("ARC ⬆️", "number", True)
20
+ hellaswag = ColumnContent("HellaSwag ⬆️", "number", True)
21
+ mmlu = ColumnContent("MMLU ⬆️", "number", True)
22
+ truthfulqa = ColumnContent("TruthfulQA (MC) ⬆️", "number", True)
23
+ model_type = ColumnContent("Type", "str", False)
24
+ precision = ColumnContent("Precision", "str", False, True)
25
+ license = ColumnContent("Hub License", "str", False)
26
+ params = ColumnContent("#Params (B)", "number", False)
27
+ likes = ColumnContent("Hub ❤️", "number", False)
28
+ revision = ColumnContent("Model sha", "str", False, False)
29
+ dummy = ColumnContent("model_name_for_query", "str", True) # dummy col to implement search bar (hidden by custom CSS)
30
+
31
+ @dataclass(frozen=True)
32
+ class EloEvalColumn: # Elo evals column
33
+ model = ColumnContent("Model", "markdown", True)
34
+ gpt4 = ColumnContent("GPT-4 (all)", "number", True)
35
+ human_all = ColumnContent("Human (all)", "number", True)
36
+ human_instruct = ColumnContent("Human (instruct)", "number", True)
37
+ human_code_instruct = ColumnContent("Human (code-instruct)", "number", True)
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class EvalQueueColumn: # Queue column
42
+ model = ColumnContent("model", "markdown", True)
43
+ revision = ColumnContent("revision", "str", True)
44
+ private = ColumnContent("private", "bool", True)
45
+ precision = ColumnContent("precision", "bool", True)
46
+ weight_type = ColumnContent("weight_type", "str", "Original")
47
+ status = ColumnContent("status", "str", True)
48
+
49
+ LLAMAS = ["huggingface/llama-7b", "huggingface/llama-13b", "huggingface/llama-30b", "huggingface/llama-65b"]
50
+
51
+
52
+ KOALA_LINK = "https://huggingface.co/TheBloke/koala-13B-HF"
53
+ VICUNA_LINK = "https://huggingface.co/lmsys/vicuna-13b-delta-v1.1"
54
+ OASST_LINK = "https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5"
55
+ DOLLY_LINK = "https://huggingface.co/databricks/dolly-v2-12b"
56
+ MODEL_PAGE = "https://huggingface.co/models"
57
+ LLAMA_LINK = "https://ai.facebook.com/blog/large-language-model-llama-meta-ai/"
58
+ VICUNA_LINK = "https://huggingface.co/CarperAI/stable-vicuna-13b-delta"
59
+ ALPACA_LINK = "https://crfm.stanford.edu/2023/03/13/alpaca.html"
60
+
61
+
62
+ def model_hyperlink(link, model_name):
63
+ return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
64
+
65
+
66
+ def make_clickable_model(model_name):
67
+ link = f"https://huggingface.co/{model_name}"
68
+
69
+ if model_name in LLAMAS:
70
+ link = LLAMA_LINK
71
+ model_name = model_name.split("/")[1]
72
+ elif model_name == "HuggingFaceH4/stable-vicuna-13b-2904":
73
+ link = VICUNA_LINK
74
+ model_name = "stable-vicuna-13b"
75
+ elif model_name == "HuggingFaceH4/llama-7b-ift-alpaca":
76
+ link = ALPACA_LINK
77
+ model_name = "alpaca-13b"
78
+ if model_name == "dolly-12b":
79
+ link = DOLLY_LINK
80
+ elif model_name == "vicuna-13b":
81
+ link = VICUNA_LINK
82
+ elif model_name == "koala-13b":
83
+ link = KOALA_LINK
84
+ elif model_name == "oasst-12b":
85
+ link = OASST_LINK
86
+ #else:
87
+ # link = MODEL_PAGE
88
+
89
+ return model_hyperlink(link, model_name)
90
+
91
+ def styled_error(error):
92
+ return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
93
+
94
+ def styled_warning(warn):
95
+ return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
96
+
97
+ def styled_message(message):
98
+ return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"