from distutils.dir_util import copy_tree from pathlib import Path from tempfile import TemporaryDirectory from huggingface_hub import snapshot_download HF_MODEL_ID="philschmid/flan-t5-xxl-sharded-fp16" # create model dir model_tar_dir = Path(HF_MODEL_ID.split("/")[-1]) model_tar_dir.mkdir() # setup temporary directory with TemporaryDirectory() as tmpdir: # download snapshot snapshot_dir = snapshot_download(repo_id=HF_MODEL_ID, cache_dir=tmpdir) # copy snapshot to model dir copy_tree(snapshot_dir, str(model_tar_dir))