Spaces:
Running
Running
Paul Hager
commited on
Commit
·
170ba5c
1
Parent(s):
5c1f78d
Removing queue code
Browse files- app.py +3 -17
- src/about.py +11 -11
- src/leaderboard/read_evals.py +20 -21
- src/populate.py +2 -2
app.py
CHANGED
@@ -7,7 +7,6 @@ from huggingface_hub import snapshot_download
|
|
7 |
from src.about import (
|
8 |
CITATION_BUTTON_LABEL,
|
9 |
CITATION_BUTTON_TEXT,
|
10 |
-
EVALUATION_QUEUE_TEXT,
|
11 |
INTRODUCTION_TEXT,
|
12 |
LLM_BENCHMARKS_TEXT,
|
13 |
TITLE,
|
@@ -24,9 +23,8 @@ from src.display.utils import (
|
|
24 |
WeightType,
|
25 |
Precision,
|
26 |
)
|
27 |
-
from src.envs import API,
|
28 |
-
from src.populate import
|
29 |
-
from src.submission.submit import add_new_eval
|
30 |
|
31 |
|
32 |
def restart_space():
|
@@ -34,18 +32,6 @@ def restart_space():
|
|
34 |
|
35 |
|
36 |
### Space initialisation
|
37 |
-
try:
|
38 |
-
print(EVAL_REQUESTS_PATH)
|
39 |
-
snapshot_download(
|
40 |
-
repo_id=QUEUE_REPO,
|
41 |
-
local_dir=EVAL_REQUESTS_PATH,
|
42 |
-
repo_type="dataset",
|
43 |
-
tqdm_class=None,
|
44 |
-
etag_timeout=30,
|
45 |
-
token=TOKEN,
|
46 |
-
)
|
47 |
-
except Exception:
|
48 |
-
restart_space()
|
49 |
try:
|
50 |
print(EVAL_RESULTS_PATH)
|
51 |
snapshot_download(
|
@@ -60,7 +46,7 @@ except Exception:
|
|
60 |
restart_space()
|
61 |
|
62 |
|
63 |
-
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH,
|
64 |
|
65 |
# (
|
66 |
# finished_eval_queue_df,
|
|
|
7 |
from src.about import (
|
8 |
CITATION_BUTTON_LABEL,
|
9 |
CITATION_BUTTON_TEXT,
|
|
|
10 |
INTRODUCTION_TEXT,
|
11 |
LLM_BENCHMARKS_TEXT,
|
12 |
TITLE,
|
|
|
23 |
WeightType,
|
24 |
Precision,
|
25 |
)
|
26 |
+
from src.envs import API, EVAL_RESULTS_PATH, REPO_ID, RESULTS_REPO, TOKEN
|
27 |
+
from src.populate import get_leaderboard_df
|
|
|
28 |
|
29 |
|
30 |
def restart_space():
|
|
|
32 |
|
33 |
|
34 |
### Space initialisation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
try:
|
36 |
print(EVAL_RESULTS_PATH)
|
37 |
snapshot_download(
|
|
|
46 |
restart_space()
|
47 |
|
48 |
|
49 |
+
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, COLS, BENCHMARK_COLS)
|
50 |
|
51 |
# (
|
52 |
# finished_eval_queue_df,
|
src/about.py
CHANGED
@@ -13,17 +13,17 @@ class Task:
|
|
13 |
# ---------------------------------------------------
|
14 |
class Tasks(Enum):
|
15 |
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
16 |
-
task0 = Task("
|
17 |
-
task1 = Task("
|
18 |
-
task2 = Task("
|
19 |
-
task3 = Task("
|
20 |
-
task4 = Task("
|
21 |
-
|
22 |
-
task5 = Task("
|
23 |
-
task6 = Task("
|
24 |
-
task7 = Task("
|
25 |
-
task8 = Task("
|
26 |
-
task9 = Task("
|
27 |
|
28 |
|
29 |
NUM_FEWSHOT = 0 # Change with your few shot
|
|
|
13 |
# ---------------------------------------------------
|
14 |
class Tasks(Enum):
|
15 |
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
16 |
+
task0 = Task("MIMIC_CDM_Appendicitis", "acc", "CDM App")
|
17 |
+
task1 = Task("MIMIC_CDM_Cholecystitis", "acc", "CDM Cholec")
|
18 |
+
task2 = Task("MIMIC_CDM_Diverticulitis", "acc", "CDM Divert")
|
19 |
+
task3 = Task("MIMIC_CDM_Pancreatitis", "acc", "CDM Pancr")
|
20 |
+
task4 = Task("MIMIC_CDM_Mean", "acc", "CDM Mean")
|
21 |
+
|
22 |
+
task5 = Task("MIMIC_CDM_FI_Appendicitis", "acc", "CDM FI App")
|
23 |
+
task6 = Task("MIMIC_CDM_FI_Cholecystitis", "acc", "CDM FI Cholec")
|
24 |
+
task7 = Task("MIMIC_CDM_FI_Diverticulitis", "acc", "CDM FI Divert")
|
25 |
+
task8 = Task("MIMIC_CDM_FI_Pancreatitis", "acc", "CDM FI Pancr")
|
26 |
+
task9 = Task("MIMIC_CDM_FI_Mean", "acc", "CDM FI Mean")
|
27 |
|
28 |
|
29 |
NUM_FEWSHOT = 0 # Change with your few shot
|
src/leaderboard/read_evals.py
CHANGED
@@ -14,22 +14,22 @@ from src.submission.check_validity import is_model_on_hub
|
|
14 |
|
15 |
@dataclass
|
16 |
class EvalResult:
|
17 |
-
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
18 |
-
|
19 |
-
eval_name: str
|
20 |
-
full_model: str
|
21 |
-
org: str
|
22 |
model: str
|
23 |
-
revision: str
|
24 |
results: dict
|
25 |
precision: Precision = Precision.Unknown
|
26 |
-
model_type: ModelType = ModelType.Unknown
|
27 |
-
weight_type: WeightType = WeightType.Original
|
28 |
-
architecture: str = "Unknown"
|
29 |
license: str = "?"
|
30 |
likes: int = 0
|
31 |
num_params: int = 0
|
32 |
-
date: str = ""
|
33 |
still_on_hub: bool = False
|
34 |
|
35 |
@classmethod
|
@@ -85,10 +85,10 @@ class EvalResult:
|
|
85 |
org=org,
|
86 |
model=model,
|
87 |
results=results,
|
88 |
-
precision=precision,
|
89 |
-
revision=
|
90 |
still_on_hub=still_on_hub,
|
91 |
-
architecture=architecture
|
92 |
)
|
93 |
|
94 |
def update_with_request_file(self, requests_path):
|
@@ -105,7 +105,9 @@ class EvalResult:
|
|
105 |
self.num_params = request.get("params", 0)
|
106 |
self.date = request.get("submitted_time", "")
|
107 |
except Exception:
|
108 |
-
print(
|
|
|
|
|
109 |
|
110 |
def to_dict(self):
|
111 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
@@ -146,15 +148,12 @@ def get_request_file_for_model(requests_path, model_name, precision):
|
|
146 |
for tmp_request_file in request_files:
|
147 |
with open(tmp_request_file, "r") as f:
|
148 |
req_content = json.load(f)
|
149 |
-
if (
|
150 |
-
req_content["status"] in ["FINISHED"]
|
151 |
-
and req_content["precision"] == precision.split(".")[-1]
|
152 |
-
):
|
153 |
request_file = tmp_request_file
|
154 |
return request_file
|
155 |
|
156 |
|
157 |
-
def get_raw_eval_results(results_path: str
|
158 |
"""From the path of the results folder root, extract all needed info for results"""
|
159 |
model_result_filepaths = []
|
160 |
|
@@ -176,7 +175,7 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
176 |
for model_result_filepath in model_result_filepaths:
|
177 |
# Creation of result
|
178 |
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
179 |
-
eval_result.update_with_request_file(requests_path)
|
180 |
|
181 |
# Store results of same eval together
|
182 |
eval_name = eval_result.eval_name
|
@@ -188,7 +187,7 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
188 |
results = []
|
189 |
for v in eval_results.values():
|
190 |
try:
|
191 |
-
v.to_dict()
|
192 |
results.append(v)
|
193 |
except KeyError: # not all eval values present
|
194 |
continue
|
|
|
14 |
|
15 |
@dataclass
|
16 |
class EvalResult:
|
17 |
+
"""Represents one full evaluation. Built from a combination of the result and request file for a given run."""
|
18 |
+
|
19 |
+
eval_name: str # org_model_precision (uid)
|
20 |
+
full_model: str # org/model (path on hub)
|
21 |
+
org: str
|
22 |
model: str
|
23 |
+
revision: str # commit hash, "" if main
|
24 |
results: dict
|
25 |
precision: Precision = Precision.Unknown
|
26 |
+
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
27 |
+
weight_type: WeightType = WeightType.Original # Original or Adapter
|
28 |
+
architecture: str = "Unknown"
|
29 |
license: str = "?"
|
30 |
likes: int = 0
|
31 |
num_params: int = 0
|
32 |
+
date: str = "" # submission date of request file
|
33 |
still_on_hub: bool = False
|
34 |
|
35 |
@classmethod
|
|
|
85 |
org=org,
|
86 |
model=model,
|
87 |
results=results,
|
88 |
+
precision=precision,
|
89 |
+
revision=config.get("model_sha", ""),
|
90 |
still_on_hub=still_on_hub,
|
91 |
+
architecture=architecture,
|
92 |
)
|
93 |
|
94 |
def update_with_request_file(self, requests_path):
|
|
|
105 |
self.num_params = request.get("params", 0)
|
106 |
self.date = request.get("submitted_time", "")
|
107 |
except Exception:
|
108 |
+
print(
|
109 |
+
f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}"
|
110 |
+
)
|
111 |
|
112 |
def to_dict(self):
|
113 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
|
|
148 |
for tmp_request_file in request_files:
|
149 |
with open(tmp_request_file, "r") as f:
|
150 |
req_content = json.load(f)
|
151 |
+
if req_content["status"] in ["FINISHED"] and req_content["precision"] == precision.split(".")[-1]:
|
|
|
|
|
|
|
152 |
request_file = tmp_request_file
|
153 |
return request_file
|
154 |
|
155 |
|
156 |
+
def get_raw_eval_results(results_path: str) -> list[EvalResult]:
|
157 |
"""From the path of the results folder root, extract all needed info for results"""
|
158 |
model_result_filepaths = []
|
159 |
|
|
|
175 |
for model_result_filepath in model_result_filepaths:
|
176 |
# Creation of result
|
177 |
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
178 |
+
# eval_result.update_with_request_file(requests_path)
|
179 |
|
180 |
# Store results of same eval together
|
181 |
eval_name = eval_result.eval_name
|
|
|
187 |
results = []
|
188 |
for v in eval_results.values():
|
189 |
try:
|
190 |
+
v.to_dict() # we test if the dict version is complete
|
191 |
results.append(v)
|
192 |
except KeyError: # not all eval values present
|
193 |
continue
|
src/populate.py
CHANGED
@@ -8,9 +8,9 @@ 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,
|
12 |
"""Creates a dataframe from all the individual experiment results"""
|
13 |
-
raw_data = get_raw_eval_results(results_path
|
14 |
all_data_json = [v.to_dict() for v in raw_data]
|
15 |
|
16 |
df = pd.DataFrame.from_records(all_data_json)
|
|
|
8 |
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
|
10 |
|
11 |
+
def get_leaderboard_df(results_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
"""Creates a dataframe from all the individual experiment results"""
|
13 |
+
raw_data = get_raw_eval_results(results_path)
|
14 |
all_data_json = [v.to_dict() for v in raw_data]
|
15 |
|
16 |
df = pd.DataFrame.from_records(all_data_json)
|