File size: 1,311 Bytes
bf6d237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import os
import argparse

from huggingface_hub import hf_hub_download, snapshot_download

from private_gpt.paths import models_path, models_cache_path
from private_gpt.settings.settings import settings

resume_download = True
if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog='Setup: Download models from huggingface')
    parser.add_argument('--resume', default=True, action=argparse.BooleanOptionalAction, help='Enable/Disable resume_download options to restart the download progress interrupted')
    args = parser.parse_args()
    resume_download = args.resume

os.makedirs(models_path, exist_ok=True)
embedding_path = models_path / "embedding"

print(f"Downloading embedding {settings().local.embedding_hf_model_name}")
snapshot_download(
    repo_id=settings().local.embedding_hf_model_name,
    cache_dir=models_cache_path,
    local_dir=embedding_path,
)
print("Embedding model downloaded!")
print("Downloading models for local execution...")

# Download LLM and create a symlink to the model file
hf_hub_download(
    repo_id=settings().local.llm_hf_repo_id,
    filename=settings().local.llm_hf_model_file,
    cache_dir=models_cache_path,
    local_dir=models_path,
    resume_download=resume_download,
)

print("LLM model downloaded!")
print("Setup done")