Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to load Adapter model of revision in repository on HF #3061

Closed
pesuchin opened this issue Nov 15, 2024 · 0 comments · Fixed by #3079
Closed

Error when trying to load Adapter model of revision in repository on HF #3061

pesuchin opened this issue Nov 15, 2024 · 0 comments · Fixed by #3079

Comments

@pesuchin
Copy link
Contributor

pesuchin commented Nov 15, 2024

Summary

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:

self.auto_model = AutoModel.from_pretrained(
model_name_or_path, config=config, cache_dir=cache_dir, **model_args
)

Proposed Fix

Currently under consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant