Alfasign edbeeching HF staff commited on
Commit
f7ef651
0 Parent(s):

Duplicate from HuggingFaceH4/open_llm_leaderboard

Browse files

Co-authored-by: Edward Beeching <edbeeching@users.noreply.huggingface.co>

Files changed (6) hide show
  1. .gitattributes +34 -0
  2. .gitignore +3 -0
  3. README.md +14 -0
  4. app.py +256 -0
  5. requirements.txt +67 -0
  6. utils.py +136 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ evals/
2
+ venv/
3
+ __pycache__/
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: false
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,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import numpy as np
4
+ import gradio as gr
5
+ from huggingface_hub import Repository, HfApi
6
+ from transformers import AutoConfig
7
+ import json
8
+ from apscheduler.schedulers.background import BackgroundScheduler
9
+ import pandas as pd
10
+ import datetime
11
+ from utils import get_eval_results_dicts, make_clickable_model
12
+
13
+ # clone / pull the lmeh eval data
14
+ H4_TOKEN = os.environ.get("H4_TOKEN", None)
15
+ LMEH_REPO = "HuggingFaceH4/lmeh_evaluations"
16
+ IS_PUBLIC = bool(os.environ.get("IS_PUBLIC", None))
17
+
18
+ repo=None
19
+ if H4_TOKEN:
20
+ print("pulling repo")
21
+ # try:
22
+ # shutil.rmtree("./evals/")
23
+ # except:
24
+ # pass
25
+
26
+ repo = Repository(
27
+ local_dir="./evals/", clone_from=LMEH_REPO, use_auth_token=H4_TOKEN, repo_type="dataset"
28
+ )
29
+ repo.git_pull()
30
+
31
+
32
+ # parse the results
33
+ BENCHMARKS = ["arc_challenge", "hellaswag", "hendrycks", "truthfulqa_mc"]
34
+
35
+ METRICS = ["acc_norm", "acc_norm", "acc_norm", "mc2"]
36
+
37
+
38
+ def load_results(model, benchmark, metric):
39
+ file_path = os.path.join("evals", model, f"{model}-eval_{benchmark}.json")
40
+ if not os.path.exists(file_path):
41
+ return 0.0, None
42
+
43
+ with open(file_path) as fp:
44
+ data = json.load(fp)
45
+ accs = np.array([v[metric] for k, v in data["results"].items()])
46
+ mean_acc = np.mean(accs)
47
+ return mean_acc, data["config"]["model_args"]
48
+
49
+
50
+ COLS = ["Model", "Revision", "Average ⬆️", "ARC (25-shot) ⬆️", "HellaSwag (10-shot) ⬆️", "MMLU (5-shot) ⬆️", "TruthQA (0-shot) ⬆️"]
51
+ TYPES = ["markdown","str", "number", "number", "number", "number", "number", ]
52
+
53
+ if not IS_PUBLIC:
54
+ COLS.insert(2, "8bit")
55
+ TYPES.insert(2, "bool")
56
+
57
+ EVAL_COLS = ["model", "revision", "private", "8bit_eval", "is_delta_weight", "status"]
58
+ EVAL_TYPES = ["markdown","str", "bool", "bool", "bool", "str"]
59
+ def get_leaderboard():
60
+ if repo:
61
+ print("pulling changes")
62
+ repo.git_pull()
63
+
64
+ all_data = get_eval_results_dicts(IS_PUBLIC)
65
+
66
+ if not IS_PUBLIC:
67
+ gpt4_values = {
68
+ "Model":f'<a target="_blank" href=https://arxiv.org/abs/2303.08774 style="color: blue; text-decoration: underline;text-decoration-style: dotted;">gpt4</a>',
69
+ "Revision":"tech report",
70
+ "8bit":None,
71
+ "Average ⬆️":84.3,
72
+ "ARC (25-shot) ⬆️":96.3,
73
+ "HellaSwag (10-shot) ⬆️":95.3,
74
+ "MMLU (5-shot) ⬆️":86.4,
75
+ "TruthQA (0-shot) ⬆️":59.0,
76
+ }
77
+ all_data.append(gpt4_values)
78
+ gpt35_values = {
79
+ "Model":f'<a target="_blank" href=https://arxiv.org/abs/2303.08774 style="color: blue; text-decoration: underline;text-decoration-style: dotted;">gpt3.5</a>',
80
+ "Revision":"tech report",
81
+ "8bit":None,
82
+ "Average ⬆️":71.9,
83
+ "ARC (25-shot) ⬆️":85.2,
84
+ "HellaSwag (10-shot) ⬆️":85.5,
85
+ "MMLU (5-shot) ⬆️":70.0,
86
+ "TruthQA (0-shot) ⬆️":47.0,
87
+ }
88
+ all_data.append(gpt35_values)
89
+
90
+ dataframe = pd.DataFrame.from_records(all_data)
91
+ dataframe = dataframe.sort_values(by=['Average ⬆️'], ascending=False)
92
+ print(dataframe)
93
+ dataframe = dataframe[COLS]
94
+ return dataframe
95
+
96
+ def get_eval_table():
97
+ if repo:
98
+ print("pulling changes for eval")
99
+ repo.git_pull()
100
+ entries = [entry for entry in os.listdir("evals/eval_requests") if not entry.startswith('.')]
101
+ all_evals = []
102
+
103
+ for entry in entries:
104
+ print(entry)
105
+ if ".json"in entry:
106
+ file_path = os.path.join("evals/eval_requests", entry)
107
+ with open(file_path) as fp:
108
+ data = json.load(fp)
109
+
110
+ data["# params"] = "unknown"
111
+ data["model"] = make_clickable_model(data["model"])
112
+ data["revision"] = data.get("revision", "main")
113
+
114
+
115
+ all_evals.append(data)
116
+ else:
117
+ # this is a folder
118
+ sub_entries = [e for e in os.listdir(f"evals/eval_requests/{entry}") if not e.startswith('.')]
119
+ for sub_entry in sub_entries:
120
+ file_path = os.path.join("evals/eval_requests", entry, sub_entry)
121
+ with open(file_path) as fp:
122
+ data = json.load(fp)
123
+
124
+ #data["# params"] = get_n_params(data["model"])
125
+ data["model"] = make_clickable_model(data["model"])
126
+ all_evals.append(data)
127
+
128
+
129
+ dataframe = pd.DataFrame.from_records(all_evals)
130
+ return dataframe[EVAL_COLS]
131
+
132
+
133
+ leaderboard = get_leaderboard()
134
+ eval_queue = get_eval_table()
135
+
136
+ def is_model_on_hub(model_name, revision) -> bool:
137
+ try:
138
+ config = AutoConfig.from_pretrained(model_name, revision=revision)
139
+ return True
140
+
141
+ except Exception as e:
142
+ print("Could not get the model config from the hub")
143
+ print(e)
144
+ return False
145
+
146
+
147
+
148
+ def add_new_eval(model:str, base_model : str, revision:str, is_8_bit_eval: bool, private:bool, is_delta_weight:bool):
149
+ # check the model actually exists before adding the eval
150
+ if revision == "":
151
+ revision = "main"
152
+ if is_delta_weight and not is_model_on_hub(base_model, revision):
153
+ print(base_model, "base model not found on hub")
154
+ return
155
+
156
+ if not is_model_on_hub(model, revision):
157
+ print(model, "not found on hub")
158
+ return
159
+ print("adding new eval")
160
+
161
+ eval_entry = {
162
+ "model" : model,
163
+ "base_model" : base_model,
164
+ "revision" : revision,
165
+ "private" : private,
166
+ "8bit_eval" : is_8_bit_eval,
167
+ "is_delta_weight" : is_delta_weight,
168
+ "status" : "PENDING"
169
+ }
170
+
171
+ user_name = ""
172
+ model_path = model
173
+ if "/" in model:
174
+ user_name = model.split("/")[0]
175
+ model_path = model.split("/")[1]
176
+
177
+ OUT_DIR=f"eval_requests/{user_name}"
178
+ os.makedirs(OUT_DIR, exist_ok=True)
179
+ out_path = f"{OUT_DIR}/{model_path}_eval_request_{private}_{is_8_bit_eval}_{is_delta_weight}.json"
180
+
181
+ with open(out_path, "w") as f:
182
+ f.write(json.dumps(eval_entry))
183
+ LMEH_REPO = "HuggingFaceH4/lmeh_evaluations"
184
+
185
+ api = HfApi()
186
+ api.upload_file(
187
+ path_or_fileobj=out_path,
188
+ path_in_repo=out_path,
189
+ repo_id=LMEH_REPO,
190
+ token=H4_TOKEN,
191
+ repo_type="dataset",
192
+ )
193
+
194
+
195
+ def refresh():
196
+ return get_leaderboard(), get_eval_table()
197
+
198
+
199
+
200
+ block = gr.Blocks()
201
+ with block:
202
+ with gr.Row():
203
+ gr.Markdown(f"""
204
+ # 🤗 Open LLM Leaderboard
205
+ <font size="4">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. The 🤗 Open LLM Leaderboard aims to track, rank and evaluate LLMs and chatbots as they are released. 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. A key advantage of this leaderboard is that 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 LLaMa.
206
+
207
+ Evaluation is performed against 4 popular benchmarks:
208
+ - <a href="https://arxiv.org/abs/1803.05457" target="_blank"> AI2 Reasoning Challenge </a> (25-shot) - a set of grade-school science questions.
209
+ - <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.
210
+ - <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.
211
+ - <a href="https://arxiv.org/abs/2109.07958" target="_blank"> Truthful QA MC </a> (0-shot) - a benchmark to measure whether a language model is truthful in generating answers to questions.
212
+
213
+ 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. </font>
214
+ """)
215
+
216
+ with gr.Row():
217
+ leaderboard_table = gr.components.Dataframe(value=leaderboard, headers=COLS,
218
+ datatype=TYPES, max_rows=5)
219
+
220
+
221
+
222
+ with gr.Row():
223
+ gr.Markdown(f"""
224
+ # Evaluation Queue for the 🤗 Open LLM Leaderboard, these models will be automatically evaluated on the 🤗 cluster
225
+
226
+ """)
227
+ with gr.Accordion("Evaluation Queue", open=False):
228
+ with gr.Row():
229
+ eval_table = gr.components.Dataframe(value=eval_queue, headers=EVAL_COLS,
230
+ datatype=EVAL_TYPES, max_rows=5)
231
+
232
+ with gr.Row():
233
+ refresh_button = gr.Button("Refresh")
234
+ refresh_button.click(refresh, inputs=[], outputs=[leaderboard_table, eval_table])
235
+
236
+ with gr.Accordion("Submit a new model for evaluation"):
237
+ # with gr.Row():
238
+ # gr.Markdown(f"""# Submit a new model for evaluation""")
239
+ with gr.Row():
240
+ with gr.Column():
241
+ model_name_textbox = gr.Textbox(label="Model name")
242
+ revision_name_textbox = gr.Textbox(label="revision", placeholder="main")
243
+
244
+ with gr.Column():
245
+ is_8bit_toggle = gr.Checkbox(False, label="8 bit eval", visible=not IS_PUBLIC)
246
+ private = gr.Checkbox(False, label="Private", visible=not IS_PUBLIC)
247
+ is_delta_weight = gr.Checkbox(False, label="Delta weights")
248
+ base_model_name_textbox = gr.Textbox(label="base model (for delta)")
249
+
250
+ with gr.Row():
251
+ submit_button = gr.Button("Submit Eval")
252
+ submit_button.click(add_new_eval, [model_name_textbox, base_model_name_textbox, revision_name_textbox, is_8bit_toggle, private, is_delta_weight])
253
+
254
+
255
+ block.load(refresh, inputs=[], outputs=[leaderboard_table, eval_table])
256
+ block.launch()
requirements.txt ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ entrypoints==0.4
15
+ fastapi==0.95.1
16
+ ffmpy==0.3.0
17
+ filelock==3.11.0
18
+ fonttools==4.39.3
19
+ frozenlist==1.3.3
20
+ fsspec==2023.4.0
21
+ gradio==3.27.0
22
+ gradio_client==0.1.3
23
+ h11==0.14.0
24
+ httpcore==0.17.0
25
+ httpx==0.24.0
26
+ huggingface-hub==0.13.4
27
+ idna==3.4
28
+ Jinja2==3.1.2
29
+ jsonschema==4.17.3
30
+ kiwisolver==1.4.4
31
+ linkify-it-py==2.0.0
32
+ markdown-it-py==2.2.0
33
+ MarkupSafe==2.1.2
34
+ matplotlib==3.7.1
35
+ mdit-py-plugins==0.3.3
36
+ mdurl==0.1.2
37
+ multidict==6.0.4
38
+ numpy==1.24.2
39
+ orjson==3.8.10
40
+ packaging==23.1
41
+ pandas==2.0.0
42
+ Pillow==9.5.0
43
+ pydantic==1.10.7
44
+ pydub==0.25.1
45
+ pyparsing==3.0.9
46
+ pyrsistent==0.19.3
47
+ python-dateutil==2.8.2
48
+ python-multipart==0.0.6
49
+ pytz==2023.3
50
+ pytz-deprecation-shim==0.1.0.post0
51
+ PyYAML==6.0
52
+ requests==2.28.2
53
+ semantic-version==2.10.0
54
+ six==1.16.0
55
+ sniffio==1.3.0
56
+ starlette==0.26.1
57
+ toolz==0.12.0
58
+ tqdm==4.65.0
59
+ transformers==4.28.1
60
+ typing_extensions==4.5.0
61
+ tzdata==2023.3
62
+ tzlocal==4.3
63
+ uc-micro-py==1.0.1
64
+ urllib3==1.26.15
65
+ uvicorn==0.21.1
66
+ websockets==11.0.1
67
+ yarl==1.8.2
utils.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import numpy as np
4
+ import gradio as gr
5
+ from huggingface_hub import Repository, HfApi
6
+ from transformers import AutoConfig, AutoModel
7
+ import json
8
+ from apscheduler.schedulers.background import BackgroundScheduler
9
+ import pandas as pd
10
+ import datetime
11
+ import glob
12
+ from dataclasses import dataclass
13
+ from typing import List, Tuple, Dict
14
+ # clone / pull the lmeh eval data
15
+ H4_TOKEN = os.environ.get("H4_TOKEN", None)
16
+ LMEH_REPO = "HuggingFaceH4/lmeh_evaluations"
17
+
18
+ METRICS = ["acc_norm", "acc_norm", "acc_norm", "mc2"]
19
+ BENCHMARKS = ["arc_challenge", "hellaswag", "hendrycks", "truthfulqa_mc"]
20
+ BENCH_TO_NAME = {
21
+ "arc_challenge":"ARC (25-shot) ⬆️",
22
+ "hellaswag":"HellaSwag (10-shot) ⬆️",
23
+ "hendrycks":"MMLU (5-shot) ⬆️",
24
+ "truthfulqa_mc":"TruthQA (0-shot) ⬆️",
25
+ }
26
+ def make_clickable_model(model_name):
27
+ LLAMAS = ["huggingface/llama-7b", "huggingface/llama-13b", "huggingface/llama-30b", "huggingface/llama-65b"]
28
+ if model_name in LLAMAS:
29
+ model = model_name.split("/")[1]
30
+ return f'<a target="_blank" href="https://ai.facebook.com/blog/large-language-model-llama-meta-ai/" style="color: blue; text-decoration: underline;text-decoration-style: dotted;">{model}</a>'
31
+
32
+ if model_name == "HuggingFaceH4/stable-vicuna-13b-2904":
33
+ link = "https://huggingface.co/" + "CarperAI/stable-vicuna-13b-delta"
34
+ return f'<a target="_blank" href="{link}" style="color: blue; text-decoration: underline;text-decoration-style: dotted;">stable-vicuna-13b</a>'
35
+
36
+ if model_name == "HuggingFaceH4/llama-7b-ift-alpaca":
37
+ link = "https://crfm.stanford.edu/2023/03/13/alpaca.html"
38
+ return f'<a target="_blank" href="{link}" style="color: blue; text-decoration: underline;text-decoration-style: dotted;">alpaca-13b</a>'
39
+
40
+ # remove user from model name
41
+ #model_name_show = ' '.join(model_name.split('/')[1:])
42
+
43
+ link = "https://huggingface.co/" + model_name
44
+ return f'<a target="_blank" href="{link}" style="color: blue; text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
45
+
46
+ @dataclass
47
+ class EvalResult:
48
+ eval_name : str
49
+ org : str
50
+ model : str
51
+ revision : str
52
+ is_8bit : bool
53
+ results : dict
54
+
55
+ def to_dict(self):
56
+
57
+ if self.org is not None:
58
+ base_model =f"{self.org}/{self.model}"
59
+ else:
60
+ base_model =f"{self.model}"
61
+ data_dict = {}
62
+
63
+ data_dict["eval_name"] = self.eval_name
64
+ data_dict["8bit"] = self.is_8bit
65
+ data_dict["Model"] = make_clickable_model(base_model)
66
+ data_dict["Revision"] = self.revision
67
+ data_dict["Average ⬆️"] = round(sum([v for k,v in self.results.items()])/4.0,1)
68
+ #data_dict["# params"] = get_n_params(base_model)
69
+
70
+ for benchmark in BENCHMARKS:
71
+ if not benchmark in self.results.keys():
72
+ self.results[benchmark] = None
73
+
74
+ for k,v in BENCH_TO_NAME.items():
75
+ data_dict[v] = self.results[k]
76
+
77
+ return data_dict
78
+
79
+
80
+
81
+
82
+ def parse_eval_result(json_filepath: str) -> Tuple[str, dict]:
83
+ with open(json_filepath) as fp:
84
+ data = json.load(fp)
85
+
86
+ path_split = json_filepath.split("/")
87
+ org = None
88
+ model = path_split[-4]
89
+ is_8bit = path_split[-2] == "8bit"
90
+ revision = path_split[-3]
91
+ if len(path_split)== 7:
92
+ # handles gpt2 type models that don't have an org
93
+ result_key = f"{path_split[-4]}_{path_split[-3]}_{path_split[-2]}"
94
+ else:
95
+ result_key = f"{path_split[-5]}_{path_split[-4]}_{path_split[-3]}_{path_split[-2]}"
96
+ org = path_split[-5]
97
+
98
+ eval_result = None
99
+ for benchmark, metric in zip(BENCHMARKS, METRICS):
100
+ if benchmark in json_filepath:
101
+ accs = np.array([v[metric] for k, v in data["results"].items()])
102
+ mean_acc = round(np.mean(accs)*100.0,1)
103
+ eval_result = EvalResult(result_key, org, model, revision, is_8bit, {benchmark:mean_acc})
104
+
105
+ return result_key, eval_result
106
+
107
+
108
+
109
+
110
+ def get_eval_results(is_public) -> List[EvalResult]:
111
+ json_filepaths = glob.glob("evals/eval_results/public/**/16bit/*.json", recursive=True)
112
+ if not is_public:
113
+ json_filepaths += glob.glob("evals/eval_results/private/**/*.json", recursive=True)
114
+ json_filepaths += glob.glob("evals/eval_results/private/**/*.json", recursive=True)
115
+ json_filepaths += glob.glob("evals/eval_results/public/**/8bit/*.json", recursive=True) # include the 8bit evals of public models
116
+ eval_results = {}
117
+
118
+ for json_filepath in json_filepaths:
119
+ result_key, eval_result = parse_eval_result(json_filepath)
120
+ if result_key in eval_results.keys():
121
+ eval_results[result_key].results.update(eval_result.results)
122
+ else:
123
+ eval_results[result_key] = eval_result
124
+
125
+
126
+ eval_results = [v for k,v in eval_results.items()]
127
+
128
+ return eval_results
129
+
130
+ def get_eval_results_dicts(is_public=True) -> List[Dict]:
131
+ eval_results = get_eval_results(is_public)
132
+
133
+ return [e.to_dict() for e in eval_results]
134
+
135
+ eval_results_dict = get_eval_results_dicts()
136
+ print(eval_results_dict)