Set the Environment Variable HF_ENDPOINT
to the mirror site (Here is
{{scheme}}://{{netloc}}).
Linux:
export HF_ENDPOINT={{scheme}}://{{netloc}}
Windows Powershell:
$env:HF_ENDPOINT = "{{scheme}}://{{netloc}}"
Starting from now on, all download operations in the HuggingFace library will be proxied through this mirror site.
from huggingface_hub import snapshot_download
snapshot_download(repo_id='Qwen/Qwen-7B', repo_type='model',
local_dir='./model_dir', resume_download=True,
max_workers=8)
Or you can download models and datasets by using huggingface cli.
pip install -U huggingface_hub
Download GPT2:
huggingface-cli download --resume-download openai-community/gpt2 --local-dir gpt2
Download WikiText:
huggingface-cli download --repo-type dataset --resume-download Salesforce/wikitext --local-dir wikitext