"""Fetch small tokenizer/index files before the large checkpoint transfers finish.""" import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) from settings import WEIGHTS, MODELS from huggingface_hub import HfApi from range_download import download if __name__ == '__main__': for key in ('llama','vicuna_delta'): repo, revision = MODELS[key] target = WEIGHTS/'sources'/key for file in HfApi().model_info(repo,revision=revision,files_metadata=True).siblings: if file.size > 2_000_000 or not file.rfilename.endswith(('.json','.model')): continue download(f'https://huggingface.co/{repo}/resolve/{revision}/{file.rfilename}', target/file.rfilename,file.size,sha256=file.lfs.sha256 if file.lfs else None, git_sha1=file.blob_id if not file.lfs else None)