Downloading model fails using snapshot_path as well as hf_hub_download

#47
by HDSB - opened

Hi There,

I am trying to download and keep the model locally instead of downloading everytime my fine-tunning works. It fails saying following reason:

File "/home/olisrsvflu/Download_model.py", line 29, in hf_model raise HFModelNotFoundError(model_str) __main__.HFModelNotFoundError: HuggingFace model not found: 'sentence-tranformers/all-MiniLM-L6_v2'

I am using following script to call using : $ python Download_model.py --model_name sentence-tranformers/all-MiniLM-L6_v2 --model_path ./modelDownload


import argparse
from multiprocessing import context
import os
from huggingface_hub import HfApi, snapshot_download, hf_hub_download

class HFModelNotFoundError(Exception):
def init(self, model_str):
super().init(f"HuggingFace model not found: '{model_str}'")
def hf_model(model_str):
api = HfApi()
models = [m.modelId for m in api.list_models()]
if model_str in models:
return model_str
else:
raise HFModelNotFoundError(model_str)

...
...

proxies = {'https_proxy':os.getenv('https_proxy'),
'http_proxy': os.getenv('http_proxy') }

snapshot_path = snapshot_download(
repo_id=args.model_name,
revision=args.revision,
cache_dir=args.model_path,
use_auth_token=True,
proxies = proxies,
)

hf_hub_download(repo_id=args.model_name, filename=args.model_path + 'miniLM_l6_V2',

proxies=proxies)

print(f"Files for '{args.model_name}' is downloaded to '{snapshot_path}'")

Sentence Transformers org

Hello!

File "/home/olisrsvflu/Download_model.py", line 29, in hf_model raise HFModelNotFoundError(model_str) main.HFModelNotFoundError: HuggingFace model not found: 'sentence-tranformers/all-MiniLM-L6_v2'

I think I see the issue: sentence-tranformers/all-MiniLM-L6_v2 should have an extra s in transformers:
sentence-tranformers/all-MiniLM-L6_v2 should be
sentence-transformers/all-MiniLM-L6_v2

  • Tom Aarsen

Tom!
I feel so foolish .... weird that I also had _v2 instead of '-v2' in it.
Thanks so much.
Jag

HDSB changed discussion status to closed
Sentence Transformers org

No worries! You're very welcome :)

Sign up or log in to comment