update `use_auth_token` -> `token` (#25083)
* update --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
parent
c53c8e490c
commit
224da5df69
|
@ -435,6 +435,8 @@ class PretrainedConfig(PushToHubMixin):
|
|||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
self._set_token_in_kwargs(kwargs)
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
raise AssertionError(f"Provided path ({save_directory}) should be a directory, not a file")
|
||||
|
||||
|
@ -463,11 +465,11 @@ class PretrainedConfig(PushToHubMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=kwargs.get("token"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _set_token_in_kwargs(self, kwargs, token=None):
|
||||
@staticmethod
|
||||
def _set_token_in_kwargs(kwargs, token=None):
|
||||
"""Temporary method to deal with `token` and `use_auth_token`.
|
||||
|
||||
This method is to avoid apply the same changes in all model config classes that overwrite `from_pretrained`.
|
||||
|
@ -490,8 +492,7 @@ class PretrainedConfig(PushToHubMixin):
|
|||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
# change to `token` in a follow-up PR
|
||||
kwargs["use_auth_token"] = token
|
||||
kwargs["token"] = token
|
||||
|
||||
@classmethod
|
||||
def from_pretrained(
|
||||
|
@ -612,6 +613,8 @@ class PretrainedConfig(PushToHubMixin):
|
|||
`Tuple[Dict, Dict]`: The dictionary(ies) that will be used to instantiate the configuration object.
|
||||
|
||||
"""
|
||||
cls._set_token_in_kwargs(kwargs)
|
||||
|
||||
original_kwargs = copy.deepcopy(kwargs)
|
||||
# Get config dict associated with the base config file
|
||||
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
|
||||
|
@ -635,7 +638,7 @@ class PretrainedConfig(PushToHubMixin):
|
|||
force_download = kwargs.pop("force_download", False)
|
||||
resume_download = kwargs.pop("resume_download", False)
|
||||
proxies = kwargs.pop("proxies", None)
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
token = kwargs.pop("token", None)
|
||||
local_files_only = kwargs.pop("local_files_only", False)
|
||||
revision = kwargs.pop("revision", None)
|
||||
trust_remote_code = kwargs.pop("trust_remote_code", None)
|
||||
|
@ -677,7 +680,7 @@ class PretrainedConfig(PushToHubMixin):
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
|
|
|
@ -360,8 +360,7 @@ class FeatureExtractionMixin(PushToHubMixin):
|
|||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
# change to `token` in a follow-up PR
|
||||
kwargs["use_auth_token"] = token
|
||||
kwargs["token"] = token
|
||||
|
||||
feature_extractor_dict, kwargs = cls.get_feature_extractor_dict(pretrained_model_name_or_path, **kwargs)
|
||||
|
||||
|
@ -382,6 +381,18 @@ class FeatureExtractionMixin(PushToHubMixin):
|
|||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
raise AssertionError(f"Provided path ({save_directory}) should be a directory, not a file")
|
||||
|
||||
|
@ -410,7 +421,7 @@ class FeatureExtractionMixin(PushToHubMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=kwargs.get("token"),
|
||||
)
|
||||
|
||||
return [output_feature_extractor_file]
|
||||
|
@ -434,10 +445,21 @@ class FeatureExtractionMixin(PushToHubMixin):
|
|||
force_download = kwargs.pop("force_download", False)
|
||||
resume_download = kwargs.pop("resume_download", False)
|
||||
proxies = kwargs.pop("proxies", None)
|
||||
token = kwargs.pop("token", None)
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
local_files_only = kwargs.pop("local_files_only", False)
|
||||
revision = kwargs.pop("revision", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
from_pipeline = kwargs.pop("_from_pipeline", None)
|
||||
from_auto_class = kwargs.pop("_from_auto", False)
|
||||
|
||||
|
@ -471,7 +493,7 @@ class FeatureExtractionMixin(PushToHubMixin):
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
)
|
||||
|
|
|
@ -361,6 +361,18 @@ class GenerationConfig(PushToHubMixin):
|
|||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
config_file_name = config_file_name if config_file_name is not None else GENERATION_CONFIG_NAME
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
|
@ -385,7 +397,7 @@ class GenerationConfig(PushToHubMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=kwargs.get("token"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -189,8 +189,7 @@ class ImageProcessingMixin(PushToHubMixin):
|
|||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
# change to `token` in a follow-up PR
|
||||
kwargs["use_auth_token"] = token
|
||||
kwargs["token"] = token
|
||||
|
||||
image_processor_dict, kwargs = cls.get_image_processor_dict(pretrained_model_name_or_path, **kwargs)
|
||||
|
||||
|
@ -211,6 +210,18 @@ class ImageProcessingMixin(PushToHubMixin):
|
|||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
raise AssertionError(f"Provided path ({save_directory}) should be a directory, not a file")
|
||||
|
||||
|
@ -239,7 +250,7 @@ class ImageProcessingMixin(PushToHubMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=kwargs.get("token"),
|
||||
)
|
||||
|
||||
return [output_image_processor_file]
|
||||
|
@ -266,6 +277,7 @@ class ImageProcessingMixin(PushToHubMixin):
|
|||
force_download = kwargs.pop("force_download", False)
|
||||
resume_download = kwargs.pop("resume_download", False)
|
||||
proxies = kwargs.pop("proxies", None)
|
||||
token = kwargs.pop("token", None)
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
local_files_only = kwargs.pop("local_files_only", False)
|
||||
revision = kwargs.pop("revision", None)
|
||||
|
@ -274,6 +286,16 @@ class ImageProcessingMixin(PushToHubMixin):
|
|||
from_pipeline = kwargs.pop("_from_pipeline", None)
|
||||
from_auto_class = kwargs.pop("_from_auto", False)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
user_agent = {"file_type": "image processor", "from_auto_class": from_auto_class}
|
||||
if from_pipeline is not None:
|
||||
user_agent["using_pipeline"] = from_pipeline
|
||||
|
@ -304,7 +326,7 @@ class ImageProcessingMixin(PushToHubMixin):
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
|
|
|
@ -727,7 +727,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||
"proxies": proxies,
|
||||
"resume_download": resume_download,
|
||||
"local_files_only": local_files_only,
|
||||
"use_auth_token": token,
|
||||
"token": token,
|
||||
"user_agent": user_agent,
|
||||
"revision": revision,
|
||||
"subfolder": subfolder,
|
||||
|
@ -758,7 +758,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||
has_file_kwargs = {
|
||||
"revision": revision,
|
||||
"proxies": proxies,
|
||||
"use_auth_token": token,
|
||||
"token": token,
|
||||
}
|
||||
if has_file(pretrained_model_name_or_path, WEIGHTS_NAME, **has_file_kwargs):
|
||||
raise EnvironmentError(
|
||||
|
@ -809,7 +809,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
|
@ -1019,7 +1019,13 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||
return model, unflatten_dict(state)
|
||||
|
||||
def save_pretrained(
|
||||
self, save_directory: Union[str, os.PathLike], params=None, push_to_hub=False, max_shard_size="10GB", **kwargs
|
||||
self,
|
||||
save_directory: Union[str, os.PathLike],
|
||||
params=None,
|
||||
push_to_hub=False,
|
||||
max_shard_size="10GB",
|
||||
token: Optional[Union[str, bool]] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Save a model and its configuration file to a directory, so that it can be re-loaded using the
|
||||
|
@ -1043,9 +1049,27 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||
|
||||
</Tip>
|
||||
|
||||
token (`str` or `bool`, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
|
||||
the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
kwargs["token"] = token
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
logger.error(f"Provided path ({save_directory}) should be a directory, not a file")
|
||||
return
|
||||
|
@ -1118,7 +1142,7 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=token,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -2335,6 +2335,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
max_shard_size: Union[int, str] = "10GB",
|
||||
create_pr: bool = False,
|
||||
safe_serialization: bool = False,
|
||||
token: Optional[Union[str, bool]] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
|
@ -2371,9 +2372,27 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
Whether or not to create a PR with the uploaded files or directly commit.
|
||||
safe_serialization (`bool`, *optional*, defaults to `False`):
|
||||
Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
|
||||
token (`str` or `bool`, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
|
||||
the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
kwargs["token"] = token
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
logger.error(f"Provided path ({save_directory}) should be a directory, not a file")
|
||||
return
|
||||
|
@ -2478,7 +2497,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=token,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -2665,7 +2684,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
local_files_only=local_files_only,
|
||||
token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
_from_auto=from_auto_class,
|
||||
_from_pipeline=from_pipeline,
|
||||
|
@ -2752,7 +2771,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
"proxies": proxies,
|
||||
"resume_download": resume_download,
|
||||
"local_files_only": local_files_only,
|
||||
"use_auth_token": token,
|
||||
"token": token,
|
||||
"user_agent": user_agent,
|
||||
"revision": revision,
|
||||
"subfolder": subfolder,
|
||||
|
@ -2799,7 +2818,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
has_file_kwargs = {
|
||||
"revision": revision,
|
||||
"proxies": proxies,
|
||||
"use_auth_token": token,
|
||||
"token": token,
|
||||
}
|
||||
if has_file(pretrained_model_name_or_path, WEIGHTS_NAME, **has_file_kwargs):
|
||||
raise EnvironmentError(
|
||||
|
@ -2846,7 +2865,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
_commit_hash=commit_hash,
|
||||
|
@ -3036,6 +3055,8 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
commit_message: Optional[str] = None,
|
||||
private: Optional[bool] = None,
|
||||
max_shard_size: Optional[Union[int, str]] = "10GB",
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
# (`use_auth_token` is deprecated)
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
create_pr: bool = False,
|
||||
**base_model_card_args,
|
||||
|
@ -3054,7 +3075,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
Message to commit while pushing. Will default to `"Upload model"`.
|
||||
private (`bool`, *optional*):
|
||||
Whether or not the repository created should be private.
|
||||
use_auth_token (`bool` or `str`, *optional*):
|
||||
token (`bool` or `str`, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url`
|
||||
is not specified.
|
||||
|
@ -3079,6 +3100,16 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
model.push_to_hub("huggingface/my-finetuned-bert")
|
||||
```
|
||||
"""
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
if "repo_path_or_name" in base_model_card_args:
|
||||
warnings.warn(
|
||||
"The `repo_path_or_name` argument is deprecated and will be removed in v5 of Transformers. Use "
|
||||
|
@ -3096,7 +3127,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
working_dir = repo_id.split("/")[-1]
|
||||
|
||||
repo_id = self._create_repo(
|
||||
repo_id, private=private, use_auth_token=use_auth_token, repo_url=repo_url, organization=organization
|
||||
repo_id, private=private, token=token, repo_url=repo_url, organization=organization
|
||||
)
|
||||
|
||||
if use_temp_dir is None:
|
||||
|
@ -3121,7 +3152,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=use_auth_token,
|
||||
token=token,
|
||||
create_pr=create_pr,
|
||||
)
|
||||
|
||||
|
|
|
@ -1665,6 +1665,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
max_shard_size: Union[int, str] = "10GB",
|
||||
safe_serialization: bool = False,
|
||||
variant: Optional[str] = None,
|
||||
token: Optional[Union[str, bool]] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
|
@ -1704,9 +1705,27 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
|
||||
variant (`str`, *optional*):
|
||||
If specified, weights are saved in the format pytorch_model.<variant>.bin.
|
||||
token (`str` or `bool`, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
|
||||
the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
kwargs["token"] = token
|
||||
|
||||
# Checks if the model has been loaded in 8-bit
|
||||
if getattr(self, "is_loaded_in_8bit", False) and getattr(self, "is_8bit_serializable", False):
|
||||
warnings.warn(
|
||||
|
@ -1872,7 +1891,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=token,
|
||||
)
|
||||
|
||||
def get_memory_footprint(self, return_buffers=True):
|
||||
|
@ -2513,7 +2532,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
"proxies": proxies,
|
||||
"resume_download": resume_download,
|
||||
"local_files_only": local_files_only,
|
||||
"use_auth_token": token,
|
||||
"token": token,
|
||||
"user_agent": user_agent,
|
||||
"revision": revision,
|
||||
"subfolder": subfolder,
|
||||
|
@ -2558,7 +2577,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
has_file_kwargs = {
|
||||
"revision": revision,
|
||||
"proxies": proxies,
|
||||
"use_auth_token": token,
|
||||
"token": token,
|
||||
}
|
||||
if has_file(pretrained_model_name_or_path, TF2_WEIGHTS_NAME, **has_file_kwargs):
|
||||
raise EnvironmentError(
|
||||
|
@ -2619,7 +2638,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import copy
|
||||
import importlib
|
||||
import os
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
|
||||
from ...configuration_utils import PretrainedConfig
|
||||
|
@ -449,8 +450,25 @@ class _BaseAutoModelClass:
|
|||
"revision",
|
||||
"subfolder",
|
||||
"use_auth_token",
|
||||
"token",
|
||||
]
|
||||
hub_kwargs = {name: kwargs.pop(name) for name in hub_kwargs_names if name in kwargs}
|
||||
|
||||
token = hub_kwargs.pop("token", None)
|
||||
use_auth_token = hub_kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
hub_kwargs["token"] = token
|
||||
|
||||
if not isinstance(config, PretrainedConfig):
|
||||
kwargs_orig = copy.deepcopy(kwargs)
|
||||
# ensure not to pollute the config object with torch_dtype="auto" - since it's
|
||||
|
|
|
@ -987,6 +987,17 @@ class AutoConfig:
|
|||
>>> unused_kwargs
|
||||
{'foo': False}
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
kwargs["_from_auto"] = True
|
||||
kwargs["name_or_path"] = pretrained_model_name_or_path
|
||||
trust_remote_code = kwargs.pop("trust_remote_code", None)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import importlib
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
|
@ -135,7 +136,7 @@ def get_feature_extractor_config(
|
|||
force_download: bool = False,
|
||||
resume_download: bool = False,
|
||||
proxies: Optional[Dict[str, str]] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
revision: Optional[str] = None,
|
||||
local_files_only: bool = False,
|
||||
**kwargs,
|
||||
|
@ -164,7 +165,7 @@ def get_feature_extractor_config(
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -176,7 +177,7 @@ def get_feature_extractor_config(
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -198,6 +199,15 @@ def get_feature_extractor_config(
|
|||
tokenizer.save_pretrained("tokenizer-test")
|
||||
tokenizer_config = get_tokenizer_config("tokenizer-test")
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
resolved_config_file = get_file_from_repo(
|
||||
pretrained_model_name_or_path,
|
||||
FEATURE_EXTRACTOR_NAME,
|
||||
|
@ -205,7 +215,7 @@ def get_feature_extractor_config(
|
|||
force_download=force_download,
|
||||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
local_files_only=local_files_only,
|
||||
)
|
||||
|
@ -269,7 +279,7 @@ class AutoFeatureExtractor:
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -292,7 +302,7 @@ class AutoFeatureExtractor:
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -307,6 +317,17 @@ class AutoFeatureExtractor:
|
|||
>>> # If feature extractor files are in a directory (e.g. feature extractor was saved using *save_pretrained('./test/saved_model/')*)
|
||||
>>> # feature_extractor = AutoFeatureExtractor.from_pretrained("./test/saved_model/")
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
config = kwargs.pop("config", None)
|
||||
trust_remote_code = kwargs.pop("trust_remote_code", None)
|
||||
kwargs["_from_auto"] = True
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import importlib
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
|
@ -143,7 +144,7 @@ def get_image_processor_config(
|
|||
force_download: bool = False,
|
||||
resume_download: bool = False,
|
||||
proxies: Optional[Dict[str, str]] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
revision: Optional[str] = None,
|
||||
local_files_only: bool = False,
|
||||
**kwargs,
|
||||
|
@ -172,7 +173,7 @@ def get_image_processor_config(
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -184,7 +185,7 @@ def get_image_processor_config(
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -206,6 +207,15 @@ def get_image_processor_config(
|
|||
image_processor.save_pretrained("image-processor-test")
|
||||
image_processor_config = get_image_processor_config("image-processor-test")
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
resolved_config_file = get_file_from_repo(
|
||||
pretrained_model_name_or_path,
|
||||
IMAGE_PROCESSOR_NAME,
|
||||
|
@ -213,7 +223,7 @@ def get_image_processor_config(
|
|||
force_download=force_download,
|
||||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
local_files_only=local_files_only,
|
||||
)
|
||||
|
@ -277,7 +287,7 @@ class AutoImageProcessor:
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -300,7 +310,7 @@ class AutoImageProcessor:
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -315,6 +325,17 @@ class AutoImageProcessor:
|
|||
>>> # If image processor files are in a directory (e.g. image processor was saved using *save_pretrained('./test/saved_model/')*)
|
||||
>>> # image_processor = AutoImageProcessor.from_pretrained("./test/saved_model/")
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
config = kwargs.pop("config", None)
|
||||
trust_remote_code = kwargs.pop("trust_remote_code", None)
|
||||
kwargs["_from_auto"] = True
|
||||
|
|
|
@ -17,6 +17,7 @@ import importlib
|
|||
import inspect
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
|
||||
# Build the list of all feature extractors
|
||||
|
@ -158,7 +159,7 @@ class AutoProcessor:
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -181,7 +182,7 @@ class AutoProcessor:
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -196,6 +197,17 @@ class AutoProcessor:
|
|||
>>> # If processor files are in a directory (e.g. processor was saved using *save_pretrained('./test/saved_model/')*)
|
||||
>>> # processor = AutoProcessor.from_pretrained("./test/saved_model/")
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
config = kwargs.pop("config", None)
|
||||
trust_remote_code = kwargs.pop("trust_remote_code", None)
|
||||
kwargs["_from_auto"] = True
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import importlib
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union
|
||||
|
||||
|
@ -426,7 +427,7 @@ def get_tokenizer_config(
|
|||
force_download: bool = False,
|
||||
resume_download: bool = False,
|
||||
proxies: Optional[Dict[str, str]] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
revision: Optional[str] = None,
|
||||
local_files_only: bool = False,
|
||||
subfolder: str = "",
|
||||
|
@ -456,7 +457,7 @@ def get_tokenizer_config(
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -471,7 +472,7 @@ def get_tokenizer_config(
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -493,6 +494,15 @@ def get_tokenizer_config(
|
|||
tokenizer.save_pretrained("tokenizer-test")
|
||||
tokenizer_config = get_tokenizer_config("tokenizer-test")
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
commit_hash = kwargs.get("_commit_hash", None)
|
||||
resolved_config_file = cached_file(
|
||||
pretrained_model_name_or_path,
|
||||
|
@ -501,7 +511,7 @@ def get_tokenizer_config(
|
|||
force_download=force_download,
|
||||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
local_files_only=local_files_only,
|
||||
subfolder=subfolder,
|
||||
|
@ -613,6 +623,17 @@ class AutoTokenizer:
|
|||
>>> # Download vocabulary from huggingface.co and define model-specific arguments
|
||||
>>> tokenizer = AutoTokenizer.from_pretrained("roberta-base", add_prefix_space=True)
|
||||
```"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
config = kwargs.pop("config", None)
|
||||
kwargs["_from_auto"] = True
|
||||
|
||||
|
|
|
@ -378,8 +378,8 @@ def convert_esm_checkpoint_to_pytorch(
|
|||
hf_tokenizer.save_pretrained(pytorch_dump_folder_path)
|
||||
|
||||
if push_to_repo:
|
||||
model.push_to_hub(repo_id=push_to_repo, use_auth_token=auth_token)
|
||||
hf_tokenizer.push_to_hub(repo_id=push_to_repo, use_auth_token=auth_token)
|
||||
model.push_to_hub(repo_id=push_to_repo, token_token=auth_token)
|
||||
hf_tokenizer.push_to_hub(repo_id=push_to_repo, token_token=auth_token)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -264,7 +264,7 @@ def convert_wav2vec2_checkpoint(
|
|||
add_adapter=True,
|
||||
adapter_stride=adapter_stride,
|
||||
adapter_kernel_size=adapter_kernel_size,
|
||||
use_auth_token=True,
|
||||
token_token=True,
|
||||
output_hidden_size=encoder_output_dim,
|
||||
)
|
||||
decoder_config = MBartConfig.from_pretrained(decoder_config_path)
|
||||
|
@ -282,7 +282,7 @@ def convert_wav2vec2_checkpoint(
|
|||
model = model[0].eval()
|
||||
|
||||
# load feature extractor
|
||||
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(encoder_config_path, use_auth_token=True)
|
||||
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(encoder_config_path, token_token=True)
|
||||
|
||||
# set weights for wav2vec2 encoder
|
||||
hf_encoder = Wav2Vec2Model(encoder_config)
|
||||
|
|
|
@ -1230,7 +1230,7 @@ class Wav2Vec2PreTrainedModel(PreTrainedModel):
|
|||
'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
|
||||
local_files_only(`bool`, *optional*, defaults to `False`):
|
||||
Whether or not to only look at local files (i.e., do not try to download the model).
|
||||
use_auth_token (`str` or `bool`, *optional*):
|
||||
token (`str` or `bool`, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
|
||||
the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -1281,10 +1281,21 @@ class Wav2Vec2PreTrainedModel(PreTrainedModel):
|
|||
resume_download = kwargs.pop("resume_download", False)
|
||||
proxies = kwargs.pop("proxies", None)
|
||||
local_files_only = kwargs.pop("local_files_only", False)
|
||||
token = kwargs.pop("token", None)
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
revision = kwargs.pop("revision", None)
|
||||
use_safetensors = kwargs.pop("use_safetensors", None if is_safetensors_available() else False)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
model_path_or_id = self.config._name_or_path
|
||||
state_dict = None
|
||||
|
||||
|
@ -1300,7 +1311,7 @@ class Wav2Vec2PreTrainedModel(PreTrainedModel):
|
|||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
cache_dir=cache_dir,
|
||||
)
|
||||
|
@ -1335,7 +1346,7 @@ class Wav2Vec2PreTrainedModel(PreTrainedModel):
|
|||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
cache_dir=cache_dir,
|
||||
)
|
||||
|
|
|
@ -114,6 +114,18 @@ class ProcessorMixin(PushToHubMixin):
|
|||
kwargs (`Dict[str, Any]`, *optional*):
|
||||
Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
os.makedirs(save_directory, exist_ok=True)
|
||||
|
||||
if push_to_hub:
|
||||
|
@ -149,7 +161,7 @@ class ProcessorMixin(PushToHubMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=kwargs.get("token"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -209,8 +221,7 @@ class ProcessorMixin(PushToHubMixin):
|
|||
token = use_auth_token
|
||||
|
||||
if token is not None:
|
||||
# change to `token` in a follow-up PR
|
||||
kwargs["use_auth_token"] = token
|
||||
kwargs["token"] = token
|
||||
|
||||
args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
|
||||
return cls(*args)
|
||||
|
|
|
@ -1681,7 +1681,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -1773,7 +1773,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
force_download=force_download,
|
||||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
use_auth_token=token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
local_files_only=local_files_only,
|
||||
subfolder=subfolder,
|
||||
|
@ -1810,7 +1810,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
|
@ -1848,7 +1848,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
pretrained_model_name_or_path,
|
||||
init_configuration,
|
||||
*init_inputs,
|
||||
use_auth_token=token,
|
||||
token=token,
|
||||
cache_dir=cache_dir,
|
||||
local_files_only=local_files_only,
|
||||
_commit_hash=commit_hash,
|
||||
|
@ -1863,7 +1863,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
pretrained_model_name_or_path,
|
||||
init_configuration,
|
||||
*init_inputs,
|
||||
use_auth_token=None,
|
||||
token=None,
|
||||
cache_dir=None,
|
||||
local_files_only=False,
|
||||
_commit_hash=None,
|
||||
|
@ -1880,7 +1880,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
pretrained_model_name_or_path,
|
||||
copy.deepcopy(init_configuration),
|
||||
*init_inputs,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
cache_dir=cache_dir,
|
||||
local_files_only=local_files_only,
|
||||
_commit_hash=_commit_hash,
|
||||
|
@ -1920,7 +1920,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
try:
|
||||
config = AutoConfig.from_pretrained(
|
||||
pretrained_model_name_or_path,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
cache_dir=cache_dir,
|
||||
local_files_only=local_files_only,
|
||||
_commit_hash=_commit_hash,
|
||||
|
@ -2139,6 +2139,18 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
Returns:
|
||||
A tuple of `str`: The files saved.
|
||||
"""
|
||||
use_auth_token = kwargs.pop("use_auth_token", None)
|
||||
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if kwargs.get("token", None) is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
kwargs["token"] = use_auth_token
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
logger.error(f"Provided path ({save_directory}) should be a directory, not a file")
|
||||
return
|
||||
|
@ -2236,7 +2248,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=kwargs.get("use_auth_token"),
|
||||
token=kwargs.get("token"),
|
||||
)
|
||||
|
||||
return save_files
|
||||
|
|
|
@ -506,7 +506,7 @@ class PipelineTool(Tool):
|
|||
if device_map is not None:
|
||||
self.model_kwargs["device_map"] = device_map
|
||||
self.hub_kwargs = hub_kwargs
|
||||
self.hub_kwargs["use_auth_token"] = token
|
||||
self.hub_kwargs["token"] = token
|
||||
|
||||
super().__init__()
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ def cached_file(
|
|||
force_download: bool = False,
|
||||
resume_download: bool = False,
|
||||
proxies: Optional[Dict[str, str]] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
revision: Optional[str] = None,
|
||||
local_files_only: bool = False,
|
||||
subfolder: str = "",
|
||||
|
@ -314,6 +314,7 @@ def cached_file(
|
|||
_raise_exceptions_for_missing_entries: bool = True,
|
||||
_raise_exceptions_for_connection_errors: bool = True,
|
||||
_commit_hash: Optional[str] = None,
|
||||
**deprecated_kwargs,
|
||||
):
|
||||
"""
|
||||
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
|
||||
|
@ -337,7 +338,7 @@ def cached_file(
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -354,7 +355,7 @@ def cached_file(
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -367,6 +368,15 @@ def cached_file(
|
|||
# Download a model weight from the Hub and cache it.
|
||||
model_weights_file = cached_file("bert-base-uncased", "pytorch_model.bin")
|
||||
```"""
|
||||
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
# Private arguments
|
||||
# _raise_exceptions_for_missing_entries: if False, do not raise an exception for missing entries but return
|
||||
# None.
|
||||
|
@ -426,7 +436,7 @@ def cached_file(
|
|||
force_download=force_download,
|
||||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
local_files_only=local_files_only,
|
||||
)
|
||||
except GatedRepoError as e:
|
||||
|
@ -490,10 +500,11 @@ def get_file_from_repo(
|
|||
force_download: bool = False,
|
||||
resume_download: bool = False,
|
||||
proxies: Optional[Dict[str, str]] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
revision: Optional[str] = None,
|
||||
local_files_only: bool = False,
|
||||
subfolder: str = "",
|
||||
**deprecated_kwargs,
|
||||
):
|
||||
"""
|
||||
Tries to locate a file in a local folder and repo, downloads and cache it if necessary.
|
||||
|
@ -517,7 +528,7 @@ def get_file_from_repo(
|
|||
proxies (`Dict[str, str]`, *optional*):
|
||||
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
||||
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
||||
use_auth_token (`str` or *bool*, *optional*):
|
||||
token (`str` or *bool*, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`).
|
||||
revision (`str`, *optional*, defaults to `"main"`):
|
||||
|
@ -532,7 +543,7 @@ def get_file_from_repo(
|
|||
|
||||
<Tip>
|
||||
|
||||
Passing `use_auth_token=True` is required when you want to use a private model.
|
||||
Passing `token=True` is required when you want to use a private model.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
@ -548,6 +559,15 @@ def get_file_from_repo(
|
|||
# This model does not have a tokenizer config so the result will be None.
|
||||
tokenizer_config = get_file_from_repo("xlm-roberta-base", "tokenizer_config.json")
|
||||
```"""
|
||||
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
return cached_file(
|
||||
path_or_repo_id=path_or_repo,
|
||||
filename=filename,
|
||||
|
@ -555,7 +575,7 @@ def get_file_from_repo(
|
|||
force_download=force_download,
|
||||
resume_download=resume_download,
|
||||
proxies=proxies,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
revision=revision,
|
||||
local_files_only=local_files_only,
|
||||
subfolder=subfolder,
|
||||
|
@ -595,7 +615,8 @@ def has_file(
|
|||
filename: str,
|
||||
revision: Optional[str] = None,
|
||||
proxies: Optional[Dict[str, str]] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
**deprecated_kwargs,
|
||||
):
|
||||
"""
|
||||
Checks if a repo contains a given file without downloading it. Works for remote repos and local folders.
|
||||
|
@ -607,11 +628,20 @@ def has_file(
|
|||
|
||||
</Tip>
|
||||
"""
|
||||
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
if os.path.isdir(path_or_repo):
|
||||
return os.path.isfile(os.path.join(path_or_repo, filename))
|
||||
|
||||
url = hf_hub_url(path_or_repo, filename=filename, revision=revision)
|
||||
headers = build_hf_headers(use_auth_token=use_auth_token, user_agent=http_user_agent())
|
||||
headers = build_hf_headers(token=token, user_agent=http_user_agent())
|
||||
|
||||
r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=10)
|
||||
try:
|
||||
|
@ -647,7 +677,7 @@ class PushToHubMixin:
|
|||
self,
|
||||
repo_id: str,
|
||||
private: Optional[bool] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
repo_url: Optional[str] = None,
|
||||
organization: Optional[str] = None,
|
||||
) -> str:
|
||||
|
@ -671,11 +701,11 @@ class PushToHubMixin:
|
|||
repo_id = repo_id.split("/")[-1]
|
||||
repo_id = f"{organization}/{repo_id}"
|
||||
|
||||
url = create_repo(repo_id=repo_id, token=use_auth_token, private=private, exist_ok=True)
|
||||
url = create_repo(repo_id=repo_id, token=token, private=private, exist_ok=True)
|
||||
|
||||
# If the namespace is not there, add it or `upload_file` will complain
|
||||
if "/" not in repo_id and url != f"{HUGGINGFACE_CO_RESOLVE_ENDPOINT}/{repo_id}":
|
||||
repo_id = get_full_repo_name(repo_id, token=use_auth_token)
|
||||
repo_id = get_full_repo_name(repo_id, token=token)
|
||||
return repo_id
|
||||
|
||||
def _get_files_timestamps(self, working_dir: Union[str, os.PathLike]):
|
||||
|
@ -749,7 +779,7 @@ class PushToHubMixin:
|
|||
use_temp_dir: Optional[bool] = None,
|
||||
commit_message: Optional[str] = None,
|
||||
private: Optional[bool] = None,
|
||||
use_auth_token: Optional[Union[bool, str]] = None,
|
||||
token: Optional[Union[bool, str]] = None,
|
||||
max_shard_size: Optional[Union[int, str]] = "10GB",
|
||||
create_pr: bool = False,
|
||||
safe_serialization: bool = False,
|
||||
|
@ -770,7 +800,7 @@ class PushToHubMixin:
|
|||
Message to commit while pushing. Will default to `"Upload {object}"`.
|
||||
private (`bool`, *optional*):
|
||||
Whether or not the repository created should be private.
|
||||
use_auth_token (`bool` or `str`, *optional*):
|
||||
token (`bool` or `str`, *optional*):
|
||||
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
|
||||
when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url`
|
||||
is not specified.
|
||||
|
@ -797,6 +827,17 @@ class PushToHubMixin:
|
|||
{object}.push_to_hub("huggingface/my-finetuned-bert")
|
||||
```
|
||||
"""
|
||||
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError(
|
||||
"`token` and `use_auth_token` are both specified. Please set only the argument `token`."
|
||||
)
|
||||
token = use_auth_token
|
||||
|
||||
if "repo_path_or_name" in deprecated_kwargs:
|
||||
warnings.warn(
|
||||
"The `repo_path_or_name` argument is deprecated and will be removed in v5 of Transformers. Use "
|
||||
|
@ -814,7 +855,7 @@ class PushToHubMixin:
|
|||
working_dir = repo_id.split("/")[-1]
|
||||
|
||||
repo_id = self._create_repo(
|
||||
repo_id, private=private, use_auth_token=use_auth_token, repo_url=repo_url, organization=organization
|
||||
repo_id, private=private, token=token, repo_url=repo_url, organization=organization
|
||||
)
|
||||
|
||||
if use_temp_dir is None:
|
||||
|
@ -831,7 +872,7 @@ class PushToHubMixin:
|
|||
repo_id,
|
||||
files_timestamps,
|
||||
commit_message=commit_message,
|
||||
token=use_auth_token,
|
||||
token=token,
|
||||
create_pr=create_pr,
|
||||
)
|
||||
|
||||
|
@ -923,11 +964,12 @@ def get_checkpoint_shard_files(
|
|||
proxies=None,
|
||||
resume_download=False,
|
||||
local_files_only=False,
|
||||
use_auth_token=None,
|
||||
token=None,
|
||||
user_agent=None,
|
||||
revision=None,
|
||||
subfolder="",
|
||||
_commit_hash=None,
|
||||
**deprecated_kwargs,
|
||||
):
|
||||
"""
|
||||
For a given model:
|
||||
|
@ -941,6 +983,15 @@ def get_checkpoint_shard_files(
|
|||
"""
|
||||
import json
|
||||
|
||||
use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
|
||||
if use_auth_token is not None:
|
||||
warnings.warn(
|
||||
"The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.", FutureWarning
|
||||
)
|
||||
if token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
token = use_auth_token
|
||||
|
||||
if not os.path.isfile(index_filename):
|
||||
raise ValueError(f"Can't find a checkpoint index ({index_filename}) in {pretrained_model_name_or_path}.")
|
||||
|
||||
|
@ -976,7 +1027,7 @@ def get_checkpoint_shard_files(
|
|||
proxies=proxies,
|
||||
resume_download=resume_download,
|
||||
local_files_only=local_files_only,
|
||||
use_auth_token=use_auth_token,
|
||||
token=token,
|
||||
user_agent=user_agent,
|
||||
revision=revision,
|
||||
subfolder=subfolder,
|
||||
|
|
|
@ -115,7 +115,7 @@ class ModelArguments:
|
|||
default="main",
|
||||
metadata={"help": "The specific model version to use (can be a branch name, tag name or commit id)."},
|
||||
)
|
||||
use_auth_token: bool = field(
|
||||
token: bool = field(
|
||||
default=False,
|
||||
metadata={
|
||||
"help": "Will use the token generated when running `huggingface-cli login` (necessary to use this script "
|
||||
|
@ -289,7 +289,7 @@ def main():
|
|||
config_kwargs = {
|
||||
"cache_dir": model_args.cache_dir,
|
||||
"revision": model_args.model_revision,
|
||||
"use_auth_token": True if model_args.use_auth_token else None,
|
||||
"token": True if model_args.token else None,
|
||||
}
|
||||
if model_args.config_name:
|
||||
config = AutoConfig.from_pretrained(model_args.config_name, **config_kwargs)
|
||||
|
@ -303,7 +303,7 @@ def main():
|
|||
"cache_dir": model_args.cache_dir,
|
||||
"use_fast": model_args.use_fast_tokenizer,
|
||||
"revision": model_args.model_revision,
|
||||
"use_auth_token": True if model_args.use_auth_token else None,
|
||||
"token": True if model_args.token else None,
|
||||
}
|
||||
if model_args.tokenizer_name:
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_args.tokenizer_name, **tokenizer_kwargs)
|
||||
|
@ -322,7 +322,7 @@ def main():
|
|||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.token else None,
|
||||
)
|
||||
else:
|
||||
logger.info("Training new model from scratch")
|
||||
|
@ -336,14 +336,14 @@ def main():
|
|||
finetuning_task=data_args.task_name,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.token else None,
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
model_args.tokenizer_name if model_args.tokenizer_name else model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_fast=model_args.use_fast_tokenizer,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.token else None,
|
||||
)
|
||||
model = AutoModelForSequenceClassification.from_pretrained(
|
||||
model_args.model_name_or_path,
|
||||
|
@ -351,7 +351,7 @@ def main():
|
|||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.token else None,
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ class ConfigPushToHubTester(unittest.TestCase):
|
|||
temperature=0.7,
|
||||
length_penalty=1.0,
|
||||
)
|
||||
config.push_to_hub("test-generation-config", use_auth_token=self._token)
|
||||
config.push_to_hub("test-generation-config", token=self._token)
|
||||
|
||||
new_config = GenerationConfig.from_pretrained(f"{USER}/test-generation-config")
|
||||
for k, v in config.to_dict().items():
|
||||
|
@ -156,9 +156,7 @@ class ConfigPushToHubTester(unittest.TestCase):
|
|||
|
||||
# Push to hub via save_pretrained
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
config.save_pretrained(
|
||||
tmp_dir, repo_id="test-generation-config", push_to_hub=True, use_auth_token=self._token
|
||||
)
|
||||
config.save_pretrained(tmp_dir, repo_id="test-generation-config", push_to_hub=True, token=self._token)
|
||||
|
||||
new_config = GenerationConfig.from_pretrained(f"{USER}/test-generation-config")
|
||||
for k, v in config.to_dict().items():
|
||||
|
@ -171,7 +169,7 @@ class ConfigPushToHubTester(unittest.TestCase):
|
|||
temperature=0.7,
|
||||
length_penalty=1.0,
|
||||
)
|
||||
config.push_to_hub("valid_org/test-generation-config-org", use_auth_token=self._token)
|
||||
config.push_to_hub("valid_org/test-generation-config-org", token=self._token)
|
||||
|
||||
new_config = GenerationConfig.from_pretrained("valid_org/test-generation-config-org")
|
||||
for k, v in config.to_dict().items():
|
||||
|
@ -184,7 +182,7 @@ class ConfigPushToHubTester(unittest.TestCase):
|
|||
# Push to hub via save_pretrained
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
config.save_pretrained(
|
||||
tmp_dir, repo_id="valid_org/test-generation-config-org", push_to_hub=True, use_auth_token=self._token
|
||||
tmp_dir, repo_id="valid_org/test-generation-config-org", push_to_hub=True, token=self._token
|
||||
)
|
||||
|
||||
new_config = GenerationConfig.from_pretrained("valid_org/test-generation-config-org")
|
||||
|
|
|
@ -119,7 +119,7 @@ class ConfigPushToHubTester(unittest.TestCase):
|
|||
config = BertConfig(
|
||||
vocab_size=99, hidden_size=32, num_hidden_layers=5, num_attention_heads=4, intermediate_size=37
|
||||
)
|
||||
config.push_to_hub("test-config", use_auth_token=self._token)
|
||||
config.push_to_hub("test-config", token=self._token)
|
||||
|
||||
new_config = BertConfig.from_pretrained(f"{USER}/test-config")
|
||||
for k, v in config.to_dict().items():
|
||||
|
@ -131,7 +131,7 @@ class ConfigPushToHubTester(unittest.TestCase):
|
|||
|
||||
# Push to hub via save_pretrained
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
config.save_pretrained(tmp_dir, repo_id="test-config", push_to_hub=True, use_auth_token=self._token)
|
||||
config.save_pretrained(tmp_dir, repo_id="test-config", push_to_hub=True, token=self._token)
|
||||
|
||||
new_config = BertConfig.from_pretrained(f"{USER}/test-config")
|
||||
for k, v in config.to_dict().items():
|
||||
|
|
Loading…
Reference in New Issue