Skip to content

Commit

Permalink
[Fix] Resolve loading private Transformer model in version 3.3.0 (#3058)
Browse files Browse the repository at this point in the history
* add: Add token and local_files_only to the find_adapter_config_file arguments.

* add: Add revision to the find_adapter_config_file arguments.

* For some reason, the part I didn't fix got fixed, so I put it back in.

* Set False as the default for local_files_only

---------

Co-authored-by: ryoji.nagata <[email protected]>
Co-authored-by: Tom Aarsen <[email protected]>
3 people authored Nov 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent e28f97d commit e156f38
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sentence_transformers/models/Transformer.py
Original file line number Diff line number Diff line change
@@ -101,7 +101,15 @@ def __init__(

def _load_config(self, model_name_or_path: str, cache_dir: str | None, backend: str, config_args: dict[str, Any]):
"""Loads the configuration of a model"""
if find_adapter_config_file(model_name_or_path) is not None:
if (
find_adapter_config_file(
model_name_or_path,
token=config_args.get("token"),
revision=config_args.get("revision"),
local_files_only=config_args.get("local_files_only", False),
)
is not None
):
if not is_peft_available():
raise Exception(
"Loading a PEFT model requires installing the `peft` package. You can install it via `pip install peft`."

0 comments on commit e156f38

Please sign in to comment.