Spaces:
Runtime error
Runtime error
ycy
commited on
Commit
·
d7c2978
1
Parent(s):
ba4f485
- app.py +1 -15
- src/display/formatting.py +2 -2
- src/display/utils.py +2 -12
- src/leaderboard/read_evals.py +25 -27
- src/populate.py +0 -1
app.py
CHANGED
|
@@ -70,23 +70,9 @@ def init_leaderboard(dataframe):
|
|
| 70 |
return Leaderboard(
|
| 71 |
value=dataframe,
|
| 72 |
datatype=[c.type for c in fields(AutoEvalColumn)],
|
| 73 |
-
# select_columns=SelectColumns(
|
| 74 |
-
# default_selection=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
|
| 75 |
-
# cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
|
| 76 |
-
# label="Select Columns to Display:",
|
| 77 |
-
# ),
|
| 78 |
search_columns=[AutoEvalColumn.model.name],
|
| 79 |
-
hide_columns=[
|
| 80 |
filter_columns=[
|
| 81 |
-
# ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
| 82 |
-
# ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
|
| 83 |
-
# ColumnFilter(
|
| 84 |
-
# AutoEvalColumn.params.name,
|
| 85 |
-
# type="slider",
|
| 86 |
-
# min=0.01,
|
| 87 |
-
# max=150,
|
| 88 |
-
# label="Select the number of parameters (B)",
|
| 89 |
-
# ),
|
| 90 |
ColumnFilter(
|
| 91 |
AutoEvalColumn.still_on_hub.name, type="boolean", label="🔑 Show Open Models Only", default=False
|
| 92 |
),
|
|
|
|
| 70 |
return Leaderboard(
|
| 71 |
value=dataframe,
|
| 72 |
datatype=[c.type for c in fields(AutoEvalColumn)],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
search_columns=[AutoEvalColumn.model.name],
|
| 74 |
+
hide_columns=["Available on the hub"],
|
| 75 |
filter_columns=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
ColumnFilter(
|
| 77 |
AutoEvalColumn.still_on_hub.name, type="boolean", label="🔑 Show Open Models Only", default=False
|
| 78 |
),
|
src/display/formatting.py
CHANGED
|
@@ -2,9 +2,9 @@ def model_hyperlink(link, model_name):
|
|
| 2 |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
| 3 |
|
| 4 |
|
| 5 |
-
def make_clickable_model(model_name):
|
| 6 |
link = f"https://huggingface.co/{model_name}"
|
| 7 |
-
return model_hyperlink(link,
|
| 8 |
|
| 9 |
|
| 10 |
def styled_error(error):
|
|
|
|
| 2 |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
| 3 |
|
| 4 |
|
| 5 |
+
def make_clickable_model(model_show , model_name):
|
| 6 |
link = f"https://huggingface.co/{model_name}"
|
| 7 |
+
return model_hyperlink(link, model_show)
|
| 8 |
|
| 9 |
|
| 10 |
def styled_error(error):
|
src/display/utils.py
CHANGED
|
@@ -24,22 +24,12 @@ class ColumnContent:
|
|
| 24 |
auto_eval_column_dict = []
|
| 25 |
#TODO
|
| 26 |
# Init
|
| 27 |
-
|
| 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 task in Tasks:
|
| 32 |
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "float", True , never_hidden= True)])
|
| 33 |
-
# Model information
|
| 34 |
-
#auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
| 35 |
-
#auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
| 36 |
-
#auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
| 37 |
-
#auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
| 38 |
-
#auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
| 39 |
-
#auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "float", False)])
|
| 40 |
-
#auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
| 41 |
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
| 42 |
-
|
| 43 |
|
| 44 |
# We use make dataclass to dynamically fill the scores from Tasks
|
| 45 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
|
|
|
| 24 |
auto_eval_column_dict = []
|
| 25 |
#TODO
|
| 26 |
# Init
|
| 27 |
+
|
| 28 |
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
|
|
|
|
|
|
| 29 |
for task in Tasks:
|
| 30 |
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "float", True , never_hidden= True)])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
| 32 |
+
|
| 33 |
|
| 34 |
# We use make dataclass to dynamically fill the scores from Tasks
|
| 35 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
src/leaderboard/read_evals.py
CHANGED
|
@@ -11,6 +11,15 @@ from src.display.formatting import make_clickable_model
|
|
| 11 |
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
|
| 12 |
from src.submission.check_validity import is_model_on_hub
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
@dataclass
|
| 16 |
class EvalResult:
|
|
@@ -18,8 +27,7 @@ class EvalResult:
|
|
| 18 |
"""
|
| 19 |
eval_name: str # org_model_precision (uid)
|
| 20 |
full_model: str # org/model (path on hub)
|
| 21 |
-
|
| 22 |
-
model: str
|
| 23 |
revision: str # commit hash, "" if main
|
| 24 |
results: dict
|
| 25 |
precision: Precision = Precision.Unknown
|
|
@@ -39,8 +47,12 @@ class EvalResult:
|
|
| 39 |
data = json.load(fp)
|
| 40 |
config = data.get("config")
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# Extract results available in this file (some results are split in several files)
|
| 45 |
results = {}
|
| 46 |
for task in Tasks:
|
|
@@ -55,11 +67,12 @@ class EvalResult:
|
|
| 55 |
results[task.benchmark] = mean_acc
|
| 56 |
|
| 57 |
return self(
|
| 58 |
-
eval_name=
|
| 59 |
-
full_model= config.get("model_name", ""),
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
)
|
| 64 |
|
| 65 |
def update_with_request_file(self, requests_path):
|
|
@@ -72,26 +85,15 @@ class EvalResult:
|
|
| 72 |
self.num_params = request.get("params", 0)
|
| 73 |
self.date = request.get("submitted_time", "")
|
| 74 |
except Exception:
|
| 75 |
-
print(f"Could not find request file for {self.
|
| 76 |
|
| 77 |
def to_dict(self):
|
| 78 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
| 79 |
|
| 80 |
-
# The first one is the average
|
| 81 |
-
#average = next(iter(self.results.values()))
|
| 82 |
data_dict = {
|
| 83 |
"eval_name": self.eval_name, # not a column, just a save name,
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
#AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
| 87 |
-
#AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
| 88 |
-
#AutoEvalColumn.architecture.name: self.architecture,
|
| 89 |
-
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
| 90 |
-
#AutoEvalColumn.revision.name: self.revision,
|
| 91 |
-
#AutoEvalColumn.average.name: average,
|
| 92 |
-
#AutoEvalColumn.license.name: self.license,
|
| 93 |
-
#AutoEvalColumn.likes.name: self.likes,
|
| 94 |
-
#AutoEvalColumn.params.name: self.num_params,
|
| 95 |
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
| 96 |
}
|
| 97 |
|
|
@@ -108,19 +110,15 @@ def get_request_file_for_model(requests_path, model_name, precision):
|
|
| 108 |
requests_path,
|
| 109 |
f"{model_name}_eval_request_*.json",
|
| 110 |
)
|
| 111 |
-
print(request_files)
|
| 112 |
request_files = glob.glob(request_files)
|
| 113 |
-
print(request_files)
|
| 114 |
# Select correct request file (precision)
|
| 115 |
request_file = ""
|
| 116 |
request_files = sorted(request_files, reverse=True)
|
| 117 |
for tmp_request_file in request_files:
|
| 118 |
-
print(tmp_request_file)
|
| 119 |
with open(tmp_request_file, "r") as f:
|
| 120 |
req_content = json.load(f)
|
| 121 |
if (
|
| 122 |
req_content["status"] in ["FINISHED"]
|
| 123 |
-
#and req_content["precision"] == precision.split(".")[-1]
|
| 124 |
):
|
| 125 |
request_file = tmp_request_file
|
| 126 |
return request_file
|
|
|
|
| 11 |
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
|
| 12 |
from src.submission.check_validity import is_model_on_hub
|
| 13 |
|
| 14 |
+
from huggingface_hub import model_info, HfApi
|
| 15 |
+
|
| 16 |
+
def is_model_open_source(org_model: str) -> bool:
|
| 17 |
+
api = HfApi()
|
| 18 |
+
try:
|
| 19 |
+
info = model_info(org_model)
|
| 20 |
+
return True
|
| 21 |
+
except Exception:
|
| 22 |
+
return False
|
| 23 |
|
| 24 |
@dataclass
|
| 25 |
class EvalResult:
|
|
|
|
| 27 |
"""
|
| 28 |
eval_name: str # org_model_precision (uid)
|
| 29 |
full_model: str # org/model (path on hub)
|
| 30 |
+
model_show : str # model name to display
|
|
|
|
| 31 |
revision: str # commit hash, "" if main
|
| 32 |
results: dict
|
| 33 |
precision: Precision = Precision.Unknown
|
|
|
|
| 47 |
data = json.load(fp)
|
| 48 |
config = data.get("config")
|
| 49 |
|
| 50 |
+
is_open = is_model_open_source(config.get("model_name", ""))
|
| 51 |
+
model_show = config.get("model_show", "")
|
| 52 |
+
if is_open:
|
| 53 |
+
model_to_show = f"🔑 {model_show}"
|
| 54 |
+
else:
|
| 55 |
+
model_to_show = f"🔒 {model_show}"
|
| 56 |
# Extract results available in this file (some results are split in several files)
|
| 57 |
results = {}
|
| 58 |
for task in Tasks:
|
|
|
|
| 67 |
results[task.benchmark] = mean_acc
|
| 68 |
|
| 69 |
return self(
|
| 70 |
+
eval_name = model_show,
|
| 71 |
+
full_model = config.get("model_name", ""),
|
| 72 |
+
model_show = model_to_show,
|
| 73 |
+
results = results,
|
| 74 |
+
revision = config.get("model_sha", ""),
|
| 75 |
+
still_on_hub = is_open,
|
| 76 |
)
|
| 77 |
|
| 78 |
def update_with_request_file(self, requests_path):
|
|
|
|
| 85 |
self.num_params = request.get("params", 0)
|
| 86 |
self.date = request.get("submitted_time", "")
|
| 87 |
except Exception:
|
| 88 |
+
print(f"Could not find request file for {self.full_model} ")
|
| 89 |
|
| 90 |
def to_dict(self):
|
| 91 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
| 92 |
|
|
|
|
|
|
|
| 93 |
data_dict = {
|
| 94 |
"eval_name": self.eval_name, # not a column, just a save name,
|
| 95 |
+
|
| 96 |
+
AutoEvalColumn.model.name: make_clickable_model(self.model_show , self.full_model),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
| 98 |
}
|
| 99 |
|
|
|
|
| 110 |
requests_path,
|
| 111 |
f"{model_name}_eval_request_*.json",
|
| 112 |
)
|
|
|
|
| 113 |
request_files = glob.glob(request_files)
|
|
|
|
| 114 |
# Select correct request file (precision)
|
| 115 |
request_file = ""
|
| 116 |
request_files = sorted(request_files, reverse=True)
|
| 117 |
for tmp_request_file in request_files:
|
|
|
|
| 118 |
with open(tmp_request_file, "r") as f:
|
| 119 |
req_content = json.load(f)
|
| 120 |
if (
|
| 121 |
req_content["status"] in ["FINISHED"]
|
|
|
|
| 122 |
):
|
| 123 |
request_file = tmp_request_file
|
| 124 |
return request_file
|
src/populate.py
CHANGED
|
@@ -15,7 +15,6 @@ def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchm
|
|
| 15 |
all_data_json = [v.to_dict() for v in raw_data]
|
| 16 |
|
| 17 |
df = pd.DataFrame.from_records(all_data_json)
|
| 18 |
-
|
| 19 |
df = df.sort_values(by=[AutoEvalColumn.task0.name], ascending=False)
|
| 20 |
df = df[cols].round(decimals=2)
|
| 21 |
|
|
|
|
| 15 |
all_data_json = [v.to_dict() for v in raw_data]
|
| 16 |
|
| 17 |
df = pd.DataFrame.from_records(all_data_json)
|
|
|
|
| 18 |
df = df.sort_values(by=[AutoEvalColumn.task0.name], ascending=False)
|
| 19 |
df = df[cols].round(decimals=2)
|
| 20 |
|