When trying to load an Adapter Model by specifying a revision in an private and public repository on HF, the following error occurs:
File "/Users/pesuchin/project/sentence-transformers/examples/debug2.py", line 7, in <module>
model = SentenceTransformer("pesuchin/revision-pesu-test",
File "/Users/pesuchin/project/sentence-transformers/sentence_transformers/SentenceTransformer.py", line 308, in __init__
modules, self.module_kwargs = self._load_sbert_model(
File "/Users/pesuchin/project/sentence-transformers/sentence_transformers/SentenceTransformer.py", line 1728, in _load_sbert_model
module = module_class(model_name_or_path, cache_dir=cache_folder, backend=self.backend, **kwargs)
File "/Users/pesuchin/project/sentence-transformers/sentence_transformers/models/Transformer.py", line 78, in __init__
self._load_model(model_name_or_path, config, cache_dir, backend, **model_args)
File "/Users/pesuchin/project/sentence-transformers/sentence_transformers/models/Transformer.py", line 138, in _load_model
self.auto_model = AutoModel.from_pretrained(
File "/Users/pesuchin/project/sentence-transformers/.venv/lib/python3.9/site-packages/transformers/models/auto/auto_factory.py", line 525, in from_pretrained
config, kwargs = AutoConfig.from_pretrained(
File "/Users/pesuchin/project/sentence-transformers/.venv/lib/python3.9/site-packages/transformers/models/auto/configuration_auto.py", line 976, in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/Users/pesuchin/project/sentence-transformers/.venv/lib/python3.9/site-packages/transformers/configuration_utils.py", line 633, in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/Users/pesuchin/project/sentence-transformers/.venv/lib/python3.9/site-packages/transformers/configuration_utils.py", line 690, in _get_config_dict
resolved_config_file = cached_file(
File "/Users/pesuchin/project/sentence-transformers/.venv/lib/python3.9/site-packages/transformers/utils/hub.py", line 432, in cached_file
raise EnvironmentError(
OSError: revision-test is not a valid git identifier (branch name, tag name or commit id) that exists for this model name. Check the model page at 'https://huggingface.co/pesuchin/revision-pesu-test' for available revisions.
Steps to Reproduce
Execute the following code using Sentence Transformers v3.3.0:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer(<Your Repository>, # example: pesuchin/revision-pesu-test
revision="revision-test",
token=<Your Token>)
Cause
When the revision is passed as an argument to the init method of the SentenceTransformer class, it is included in model_args and shared with the Transformer class.
As a result, in the following code, AutoModel uses model_args, which contains both the repository name of the base model and the revision where the adapter model is located. This leads to a mismatch between the repository and the revision, causing an attempt to access a nonexistent revision and resulting in an error:
Summary
When trying to load an Adapter Model by specifying a revision in an private and public repository on HF, the following error occurs:
Steps to Reproduce
Execute the following code using Sentence Transformers v3.3.0:
Cause
When the revision is passed as an argument to the init method of the SentenceTransformer class, it is included in model_args and shared with the Transformer class.
As a result, in the following code, AutoModel uses model_args, which contains both the repository name of the base model and the revision where the adapter model is located. This leads to a mismatch between the repository and the revision, causing an attempt to access a nonexistent revision and resulting in an error:
https://github.com/UKPLab/sentence-transformers/blob/c1775a67a36123ec8be7f302c6335652e83da213/sentence_transformers/models/Transformer.py#L130-L132
Proposed Fix
Currently under consideration.