diff --git a/src/transformers/integrations/peft.py b/src/transformers/integrations/peft.py index 3c274804afc6..f3a9e04912b2 100644 --- a/src/transformers/integrations/peft.py +++ b/src/transformers/integrations/peft.py @@ -106,6 +106,7 @@ def load_adapter( low_cpu_mem_usage: bool = False, is_trainable: bool = False, hotswap: bool | Literal["auto"] = "auto", + local_files_only: bool = False, adapter_kwargs: dict[str, Any] | None = None, ) -> None: """ @@ -278,6 +279,7 @@ def load_adapter( adapter_config_file = find_adapter_config_file( peft_model_id, token=token, + local_files_only=local_files_only, **adapter_kwargs, ) @@ -290,6 +292,7 @@ def load_adapter( peft_config = PeftConfig.from_pretrained( peft_model_id, token=token, + local_files_only=local_files_only, **adapter_kwargs, ) peft_config.inference_mode = not is_trainable @@ -306,6 +309,8 @@ def load_adapter( self._hf_peft_config_loaded = True if peft_model_id is not None: + if "local_files_only" not in adapter_kwargs: + adapter_kwargs["local_files_only"] = local_files_only adapter_state_dict = load_peft_weights(peft_model_id, token=token, device=device, **adapter_kwargs) # We need to pre-process the state dict to remove unneeded prefixes - for backward compatibility diff --git a/src/transformers/pipelines/__init__.py b/src/transformers/pipelines/__init__.py index 5b8e3f6b221c..960057283c63 100755 --- a/src/transformers/pipelines/__init__.py +++ b/src/transformers/pipelines/__init__.py @@ -687,12 +687,14 @@ def pipeline( code_revision = kwargs.pop("code_revision", None) commit_hash = kwargs.pop("_commit_hash", None) + local_files_only = kwargs.get("local_files_only", False) hub_kwargs = { "revision": revision, "token": token, "trust_remote_code": trust_remote_code, "_commit_hash": commit_hash, + "local_files_only": local_files_only } if task is None and model is None: