Downloading a model from the hub without loading it
Is there a way to download a model with the same API as in.from_pretrainedbut without loading it? I want to separate the two steps. I’m already aware ofhuggingface_hub.snapshot_downloadbut it downloads the whole repo, whereas.from_pretrainedis more finegrained and only downloads .safetensors for instance if I pass the appropriate flags.
2023-08-01T08:54:15Z
Hi,i tried:from huggingface_hub import REDACTED_TOKEN_url, REDACTED_TOKEN_download

# Generate/show the URL
REDACTED_TOKEN_url(
   repo_id=model,
   filename="file_name",
)

# Download the file
REDACTED_TOKEN_download(
   repo_id=model,
   filename=filename,
    local_dir = "/kaggle/working/"
)i do not know your use case, but would love to hear.Regards,Ankush Singal
2023-08-11T11:02:36Z
Hi, thank you for your answer, I was aware of this solution too but this unfortunately requires to know in advance all the files that need to be downloaded. I could create a wrapper for this, it’s not too difficult, but I figured that this is common enough that there may be a simpler way, as easy as.from_pretrained.
2023-10-12T02:01:22Z
hi@bilelomranidid you ever resolve this? I’m running in the same issue and working if theres a more idiomatic way to download files without knowing which one I need beforehand.
2023-10-17T12:43:06Z
hi@trunghnguyen, I haven’t found an idiomatic way of doing it withtransformersunfortunately. I switched to thecurated-transformerslibrary maintained by Explosion for this use case, it provides afrom_REDACTED_TOKEN_to_cachemethod that integrated well with the HuggingFace Hub. It is exactly what I was looking for.
2023-11-06T12:23:29Z
Hey@bilelomrani. Could you provide us the code snippet u used to download usingfrom_REDACTED_TOKEN_to_cache