26
26
27
27
from ..transformers .configuration_utils import PretrainedConfig
28
28
from ..utils import GENERATION_CONFIG_NAME
29
- from ..utils .download import resolve_file_path
29
+ from ..utils .download import DownloadSource , resolve_file_path
30
30
from ..utils .downloader import hf_file_exists
31
31
from ..utils .log import logger
32
32
@@ -337,9 +337,7 @@ def save_pretrained(
337
337
def from_pretrained (
338
338
cls ,
339
339
pretrained_model_name_or_path : Union [str , os .PathLike ],
340
- from_hf_hub : bool = False ,
341
- from_aistudio : bool = False ,
342
- from_modelscope : bool = False ,
340
+ download_hub : DownloadSource = None ,
343
341
config_file_name : Optional [Union [str , os .PathLike ]] = None ,
344
342
cache_dir : Optional [Union [str , os .PathLike ]] = None ,
345
343
force_download : bool = False ,
@@ -358,8 +356,8 @@ def from_pretrained(
358
356
- a path to a *directory* containing a configuration file saved using the
359
357
[`~PretrainedConfig.save_pretrained`] method, e.g., `./my_model_directory/`.
360
358
- a path or url to a saved configuration JSON *file*, e.g., `./my_model_directory/configuration.json`.
361
- from_hf_hub (bool , *optional*):
362
- load config from huggingface hub: https:// huggingface.co/models
359
+ download_hub (DownloadSource , *optional*):
360
+ The source for model downloading, options include ` huggingface`, `aistudio`, `modelscope`, default `aistudio`.
363
361
cache_dir (`str` or `os.PathLike`, *optional*):
364
362
Path to a directory in which a downloaded pretrained model configuration should be cached if the
365
363
standard cache should not be used.
@@ -418,9 +416,7 @@ def from_pretrained(
418
416
subfolder ,
419
417
cache_dir = cache_dir ,
420
418
force_download = force_download ,
421
- from_aistudio = from_aistudio ,
422
- from_hf_hub = from_hf_hub ,
423
- from_modelscope = from_modelscope ,
419
+ download_hub = download_hub ,
424
420
)
425
421
assert (
426
422
resolved_config_file is not None
0 commit comments