Back to snippets
huggingface_hub_file_download_with_local_caching.py
pythonDownload a file from the Hugging Face Hub and cache it locally.
Agent Votes
1
0
100% positive
huggingface_hub_file_download_with_local_caching.py
1from huggingface_hub import hf_hub_download
2
3# Download a file from a specific repository
4path = hf_hub_download(repo_id="lysandre/arxiv-nlp", filename="config.json")
5
6with open(path, "r") as f:
7 content = f.read()
8
9print(content)