Spaces:
Runtime error
Runtime error
Andrea Seveso
commited on
Commit
·
dc347e2
1
Parent(s):
fd6f23a
License
Browse files- src/display/utils.py +0 -2
- src/leaderboard/read_evals.py +0 -5
- src/submission/check_validity.py +15 -14
src/display/utils.py
CHANGED
@@ -37,8 +37,6 @@ for task in Tasks:
|
|
37 |
# Model information
|
38 |
auto_eval_column_dict.append(
|
39 |
["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
40 |
-
auto_eval_column_dict.append(
|
41 |
-
["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
42 |
auto_eval_column_dict.append(
|
43 |
["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
44 |
auto_eval_column_dict.append(
|
|
|
37 |
# Model information
|
38 |
auto_eval_column_dict.append(
|
39 |
["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
|
|
|
|
40 |
auto_eval_column_dict.append(
|
41 |
["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
42 |
auto_eval_column_dict.append(
|
src/leaderboard/read_evals.py
CHANGED
@@ -100,7 +100,6 @@ class EvalResult:
|
|
100 |
with open(request_file, "r") as f:
|
101 |
request = json.load(f)
|
102 |
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
103 |
-
self.license = request.get("license", "?")
|
104 |
self.likes = request.get("likes", 0)
|
105 |
self.num_params = request.get("params", 0)
|
106 |
self.date = request.get("submitted_time", "")
|
@@ -117,14 +116,10 @@ class EvalResult:
|
|
117 |
AutoEvalColumn.precision.name: self.precision.value.name,
|
118 |
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
119 |
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
120 |
-
AutoEvalColumn.architecture.name: self.architecture,
|
121 |
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
122 |
AutoEvalColumn.revision.name: self.revision,
|
123 |
# AutoEvalColumn.average.name: average,
|
124 |
-
AutoEvalColumn.license.name: self.license,
|
125 |
-
AutoEvalColumn.likes.name: self.likes,
|
126 |
AutoEvalColumn.params.name: self.num_params,
|
127 |
-
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
128 |
}
|
129 |
|
130 |
for task in Tasks:
|
|
|
100 |
with open(request_file, "r") as f:
|
101 |
request = json.load(f)
|
102 |
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
|
|
103 |
self.likes = request.get("likes", 0)
|
104 |
self.num_params = request.get("params", 0)
|
105 |
self.date = request.get("submitted_time", "")
|
|
|
116 |
AutoEvalColumn.precision.name: self.precision.value.name,
|
117 |
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
118 |
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
|
|
119 |
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
120 |
AutoEvalColumn.revision.name: self.revision,
|
121 |
# AutoEvalColumn.average.name: average,
|
|
|
|
|
122 |
AutoEvalColumn.params.name: self.num_params,
|
|
|
123 |
}
|
124 |
|
125 |
for task in Tasks:
|
src/submission/check_validity.py
CHANGED
@@ -10,34 +10,30 @@ from huggingface_hub.hf_api import ModelInfo
|
|
10 |
from transformers import AutoConfig
|
11 |
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
12 |
|
|
|
13 |
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
14 |
-
"""Checks if the model card
|
15 |
try:
|
16 |
card = ModelCard.load(repo_id)
|
17 |
except huggingface_hub.utils.EntryNotFoundError:
|
18 |
return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
|
19 |
|
20 |
-
# Enforce license metadata
|
21 |
-
if card.data.license is None:
|
22 |
-
if not ("license_name" in card.data and "license_link" in card.data):
|
23 |
-
return False, (
|
24 |
-
"License not found. Please add a license to your model card using the `license` metadata or a"
|
25 |
-
" `license_name`/`license_link` pair."
|
26 |
-
)
|
27 |
-
|
28 |
# Enforce card content
|
29 |
if len(card.text) < 200:
|
30 |
return False, "Please add a description to your model card, it is too short."
|
31 |
|
32 |
return True, ""
|
33 |
|
|
|
34 |
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
35 |
"""Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
|
36 |
try:
|
37 |
-
config = AutoConfig.from_pretrained(
|
|
|
38 |
if test_tokenizer:
|
39 |
try:
|
40 |
-
tk = AutoTokenizer.from_pretrained(
|
|
|
41 |
except ValueError as e:
|
42 |
return (
|
43 |
False,
|
@@ -66,14 +62,17 @@ def get_model_size(model_info: ModelInfo, precision: str):
|
|
66 |
except (AttributeError, TypeError):
|
67 |
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
68 |
|
69 |
-
size_factor = 8 if (
|
|
|
70 |
model_size = size_factor * model_size
|
71 |
return model_size
|
72 |
|
|
|
73 |
def get_model_arch(model_info: ModelInfo):
|
74 |
"""Gets the model architecture from the configuration"""
|
75 |
return model_info.config.get("architectures", "Unknown")
|
76 |
|
|
|
77 |
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
78 |
"""Gather a list of already submitted models to avoid duplicates"""
|
79 |
depth = 1
|
@@ -88,12 +87,14 @@ def already_submitted_models(requested_models_dir: str) -> set[str]:
|
|
88 |
continue
|
89 |
with open(os.path.join(root, file), "r") as f:
|
90 |
info = json.load(f)
|
91 |
-
file_names.append(
|
|
|
92 |
|
93 |
# Select organisation
|
94 |
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
95 |
continue
|
96 |
organisation, _ = info["model"].split("/")
|
97 |
-
users_to_submission_dates[organisation].append(
|
|
|
98 |
|
99 |
return set(file_names), users_to_submission_dates
|
|
|
10 |
from transformers import AutoConfig
|
11 |
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
12 |
|
13 |
+
|
14 |
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
15 |
+
"""Checks if the model card exist and have been filled"""
|
16 |
try:
|
17 |
card = ModelCard.load(repo_id)
|
18 |
except huggingface_hub.utils.EntryNotFoundError:
|
19 |
return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Enforce card content
|
22 |
if len(card.text) < 200:
|
23 |
return False, "Please add a description to your model card, it is too short."
|
24 |
|
25 |
return True, ""
|
26 |
|
27 |
+
|
28 |
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
29 |
"""Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
|
30 |
try:
|
31 |
+
config = AutoConfig.from_pretrained(
|
32 |
+
model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
33 |
if test_tokenizer:
|
34 |
try:
|
35 |
+
tk = AutoTokenizer.from_pretrained(
|
36 |
+
model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
37 |
except ValueError as e:
|
38 |
return (
|
39 |
False,
|
|
|
62 |
except (AttributeError, TypeError):
|
63 |
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
64 |
|
65 |
+
size_factor = 8 if (
|
66 |
+
precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
67 |
model_size = size_factor * model_size
|
68 |
return model_size
|
69 |
|
70 |
+
|
71 |
def get_model_arch(model_info: ModelInfo):
|
72 |
"""Gets the model architecture from the configuration"""
|
73 |
return model_info.config.get("architectures", "Unknown")
|
74 |
|
75 |
+
|
76 |
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
77 |
"""Gather a list of already submitted models to avoid duplicates"""
|
78 |
depth = 1
|
|
|
87 |
continue
|
88 |
with open(os.path.join(root, file), "r") as f:
|
89 |
info = json.load(f)
|
90 |
+
file_names.append(
|
91 |
+
f"{info['model']}_{info['revision']}_{info['precision']}")
|
92 |
|
93 |
# Select organisation
|
94 |
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
95 |
continue
|
96 |
organisation, _ = info["model"].split("/")
|
97 |
+
users_to_submission_dates[organisation].append(
|
98 |
+
info["submitted_time"])
|
99 |
|
100 |
return set(file_names), users_to_submission_dates
|