Commit
•
6eb8bfd
1
Parent(s):
daf60ae
Update src/submission/check_validity.py
Browse files
src/submission/check_validity.py
CHANGED
@@ -31,26 +31,20 @@ def check_model_card(repo_id: str) -> tuple[bool, str]:
|
|
31 |
|
32 |
return True, ""
|
33 |
|
34 |
-
|
35 |
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
36 |
-
"""Makes sure the model is on the hub, and uses a valid configuration (in the latest transformers version)"""
|
37 |
try:
|
38 |
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
39 |
if test_tokenizer:
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
else:
|
44 |
-
tokenizer_class_candidate = config.tokenizer_class
|
45 |
-
|
46 |
-
|
47 |
-
tokenizer_class = tokenizer_class_from_name(tokenizer_class_candidate)
|
48 |
-
if tokenizer_class is None:
|
49 |
return (
|
50 |
False,
|
51 |
-
f"uses
|
52 |
None
|
53 |
)
|
|
|
|
|
54 |
return True, None, config
|
55 |
|
56 |
except ValueError:
|
|
|
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 |
try:
|
36 |
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
37 |
if test_tokenizer:
|
38 |
+
try:
|
39 |
+
tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
40 |
+
except ValueError as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
return (
|
42 |
False,
|
43 |
+
f"uses a tokenizer which is not in a transformers release: {e}",
|
44 |
None
|
45 |
)
|
46 |
+
except Exception as e:
|
47 |
+
return (False, "'s tokenizer cannot be loaded. Is your tokenizer class in a stable transformers release, and correctly configured?", None)
|
48 |
return True, None, config
|
49 |
|
50 |
except ValueError:
|