Problems encountered when loading the model for offline operation using SentenceTransformer

#12
by HT-NEKO - opened

Sincerely ask for help, I can't load gte-base-en-v1.5 through SentenceTransformer.

Prerequisite: I have modified config.json according to the above reply, and put the two python files into the gte-base-en-v1.5 model path.

The following code can run normally offline:

model_path = "/Users/aaa/Downloads/models/gte-base-en-v1.5"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True)

But when I use SentenceTransformer:

from sentence_transformers import SentenceTransformer
model_name = "/Users/aaa/Downloads/models/gte-base-en-v1.5"
model = SentenceTransformer(model_name, trust_remote_code=True)

It will report an error:

Traceback (most recent call last):
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/sentence_transformers/util.py", line 1395, in load_dir_path 
repo_path = snapshot_download(**download_kwargs) 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 106, in _inner_fn 
validate_repo_id(arg_value) 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 154, in validate_repo_id 
raiseHFValidationError(
huggingface_hub.errors.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/Users/aaa/Downloads/models/gte-base-en-v1.5'. Use `repo_type` argument if needed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): 
File "_.py", line 160, in <module> 
model = SentenceTransformer(model_name, trust_remote_code=True) 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/sentence_transformers/SentenceTransformer.py", line 306, in __init__ 
modules, self.module_kwargs = self._load_sbert_model( 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/sentence_transformers/SentenceTransformer.py", line 1730, in _load_sbert_model 
module_path = load_dir_path( 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/sentence_transformers/util.py", line 1399, in load_dir_path 
repo_path = snapshot_download(**download_kwargs) 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 106, in _inner_fn 
validate_repo_id(arg_value) 
File "/Users/aaa/miniforge3/envs/multi-cpr/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 154, in validate_repo_id 
raiseHFValidationError(
huggingface_hub.errors.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/Users/aaa/Downloads/models/gte-base-en-v1.5'. Use `repo_type` argument if needed.

My environment:

python: 3.8.20
transformers: 4.46.3
sentence-transformers: 3.2.1

Sign up or log in to comment