File size: 915 Bytes
1c9b5b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""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)