File tree Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change 13
13
14
14
from model2vec .distill .inference import create_embeddings
15
15
from model2vec .distill .tokenizer import replace_vocabulary
16
- from model2vec .distill .utils import Token , select_optimal_device
16
+ from model2vec .distill .utils import select_optimal_device
17
17
from model2vec .model import StaticModel
18
18
from model2vec .quantization import DType , quantize_embeddings
19
19
20
- try :
21
- # For huggingface_hub>=0.25.0
22
- from huggingface_hub .errors import RepositoryNotFoundError
23
- except ImportError :
24
- # For huggingface_hub<0.25.0
25
- from huggingface_hub .utils ._errors import RepositoryNotFoundError
26
-
27
-
28
20
logger = logging .getLogger (__name__ )
29
21
30
22
@@ -137,8 +129,9 @@ def distill_from_model(
137
129
try :
138
130
info = model_info (model_name )
139
131
language = info .cardData .get ("language" , None )
140
- except RepositoryNotFoundError :
141
- logger .info ("No model info found for the model. Setting language to None." )
132
+ except Exception as e :
133
+ # NOTE: bare except because there's many reasons this can fail.
134
+ logger .warning (f"Couldn't get the model info from the Hugging Face Hub: { e } . Setting language to None." )
142
135
language = None
143
136
144
137
return StaticModel (
Original file line number Diff line number Diff line change @@ -158,8 +158,9 @@ def load_pretrained(
158
158
)
159
159
)
160
160
metadata = _get_metadata_from_readme (Path (readme_path ))
161
- except huggingface_hub .utils .EntryNotFoundError :
162
- logger .info ("No README found in the model folder. No model card loaded." )
161
+ except Exception as e :
162
+ # NOTE: we don't want to raise an error here, since the README is optional.
163
+ logger .info (f"No README found in the model folder: { e } No model card loaded." )
163
164
metadata = {}
164
165
165
166
config_path = Path (
You can’t perform that action at this time.
0 commit comments