Jacqueline Garrahan
commited on
Fix submission checks
Browse files- src/envs.py +4 -0
- src/leaderboard/read_evals.py +10 -4
- src/submission/check_validity.py +5 -1
- src/submission/submit.py +2 -2
src/envs.py
CHANGED
@@ -15,6 +15,10 @@ RESULTS_REPO = f"{OWNER}/aiera-leaderboard-results"
|
|
15 |
# If you setup a cache later, just change HF_HOME
|
16 |
CACHE_PATH=os.getenv("HF_HOME", ".")
|
17 |
|
|
|
|
|
|
|
|
|
18 |
# Local caches
|
19 |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
20 |
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
|
|
15 |
# If you setup a cache later, just change HF_HOME
|
16 |
CACHE_PATH=os.getenv("HF_HOME", ".")
|
17 |
|
18 |
+
# NO
|
19 |
+
EXTERNAL_PROVIDERS = ["openai", "anthropic", "google"]
|
20 |
+
|
21 |
+
|
22 |
# Local caches
|
23 |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
24 |
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
src/leaderboard/read_evals.py
CHANGED
@@ -10,6 +10,7 @@ import numpy as np
|
|
10 |
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
|
@@ -57,10 +58,15 @@ class EvalResult:
|
|
57 |
result_key = f"{org}_{model}_{precision.value.name}"
|
58 |
full_model = "/".join(org_and_model)
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
64 |
if model_config is not None:
|
65 |
architectures = getattr(model_config, "architectures", None)
|
66 |
if architectures:
|
|
|
10 |
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 |
+
from src.envs import EXTERNAL_PROVIDERS
|
14 |
|
15 |
|
16 |
@dataclass
|
|
|
58 |
result_key = f"{org}_{model}_{precision.value.name}"
|
59 |
full_model = "/".join(org_and_model)
|
60 |
|
61 |
+
architecture = None
|
62 |
+
model_config = None
|
63 |
+
still_on_hub = False
|
64 |
+
if not any([org.lower() in provider for provider in EXTERNAL_PROVIDERS]):
|
65 |
+
still_on_hub, _, model_config = is_model_on_hub(
|
66 |
+
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
67 |
+
)
|
68 |
+
architecture = "?"
|
69 |
+
|
70 |
if model_config is not None:
|
71 |
architectures = getattr(model_config, "architectures", None)
|
72 |
if architectures:
|
src/submission/check_validity.py
CHANGED
@@ -9,6 +9,8 @@ from huggingface_hub import ModelCard
|
|
9 |
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 and license exist and have been filled"""
|
@@ -33,8 +35,10 @@ def check_model_card(repo_id: str) -> tuple[bool, str]:
|
|
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 |
-
|
|
|
38 |
if test_tokenizer:
|
39 |
try:
|
40 |
tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
|
|
9 |
from huggingface_hub.hf_api import ModelInfo
|
10 |
from transformers import AutoConfig
|
11 |
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
12 |
+
from src.envs import API
|
13 |
+
|
14 |
|
15 |
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
16 |
"""Checks if the model card and license exist and have been filled"""
|
|
|
35 |
|
36 |
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
37 |
"""Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
|
38 |
+
model_info = API.model_info(model_name, revision="main")
|
39 |
try:
|
40 |
+
model_info = API.model_info(model_name)
|
41 |
+
config = model_info.config
|
42 |
if test_tokenizer:
|
43 |
try:
|
44 |
tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
src/submission/submit.py
CHANGED
@@ -45,12 +45,12 @@ def add_new_eval(
|
|
45 |
|
46 |
# Is the model on the hub?
|
47 |
if weight_type in ["Delta", "Adapter"]:
|
48 |
-
base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=
|
49 |
if not base_model_on_hub:
|
50 |
return styled_error(f'Base model "{base_model}" {error}')
|
51 |
|
52 |
if not weight_type == "Adapter":
|
53 |
-
model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=
|
54 |
if not model_on_hub:
|
55 |
return styled_error(f'Model "{model}" {error}')
|
56 |
|
|
|
45 |
|
46 |
# Is the model on the hub?
|
47 |
if weight_type in ["Delta", "Adapter"]:
|
48 |
+
base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=False)
|
49 |
if not base_model_on_hub:
|
50 |
return styled_error(f'Base model "{base_model}" {error}')
|
51 |
|
52 |
if not weight_type == "Adapter":
|
53 |
+
model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=False)
|
54 |
if not model_on_hub:
|
55 |
return styled_error(f'Model "{model}" {error}')
|
56 |
|