File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -512,7 +512,7 @@ def _cached_file(
512
512
# locates a file in a local folder and repo, downloads and cache it if necessary.
513
513
model_path = Path (model_path )
514
514
if model_path .is_dir ():
515
- model_cache_path = model_path / file_name
515
+ model_cache_path = model_path / subfolder / file_name
516
516
else :
517
517
file_name = Path (file_name )
518
518
if file_name .suffix != ".onnx" :
Original file line number Diff line number Diff line change @@ -324,6 +324,20 @@ def test_load_model_from_hub_private_with_token(self):
324
324
self .assertIsInstance (model .config , PretrainedConfig )
325
325
self .assertTrue (model .stateful )
326
326
327
+ @parameterized .expand (("" , "openvino" ))
328
+ def test_loading_with_config_in_root (self , subfolder ):
329
+ # config.json file in the root directory and not in the subfolder
330
+ model_id = "sentence-transformers-testing/stsb-bert-tiny-openvino"
331
+ export = subfolder == ""
332
+ # hub model
333
+ OVModelForFeatureExtraction .from_pretrained (model_id , subfolder = subfolder , export = export )
334
+ # local model
335
+ api = HfApi ()
336
+ with tempfile .TemporaryDirectory () as tmpdirname :
337
+ local_dir = Path (tmpdirname ) / "model"
338
+ api .snapshot_download (repo_id = model_id , local_dir = local_dir )
339
+ OVModelForFeatureExtraction .from_pretrained (local_dir , subfolder = subfolder , export = export )
340
+
327
341
def test_infer_export_when_loading (self ):
328
342
model_id = MODEL_NAMES ["phi" ]
329
343
model = AutoModelForCausalLM .from_pretrained (model_id )
You can’t perform that action at this time.
0 commit comments