# Downloading a model from the hub without loading it

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%3E%5C
**Category:** 🤗Transformers\
**Created:** [July 27, 2023, 10:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377 "2023-07-27T10:37:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilelomrani](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bilelomrani/32/12193_2.png) [@bilelomrani](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbilelomrani)%5C
**Post date:** [July 27, 2023, 10:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F1 "2023-07-27T10:37:08Z")

</div>

Is there a way to download a model with the same API as in `.from_pretrained` but without loading it? I want to separate the two steps. I’m already aware of `huggingface_hub.snapshot_download` but it downloads the whole repo, whereas `.from_pretrained` is more finegrained and only downloads .safetensors for instance if I pass the appropriate flags.

---

<div class="post-metadata">

**Author:** ![Andyrasika](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/andyrasika/32/31603_2.png) [@Andyrasika](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAndyrasika)%5C
**Post date:** [August 1, 2023, 8:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F2 "2023-08-01T08:54:15Z")

</div>

Hi,  
i tried:

```auto
from huggingface_hub import hf_hub_url, hf_hub_download

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

# Download the file
hf_hub_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

---

<div class="post-metadata">

**Author:** ![bilelomrani](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bilelomrani/32/12193_2.png) [@bilelomrani](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbilelomrani)%5C
**Post date:** [August 11, 2023, 11:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F3 "2023-08-11T11:02:36Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![trunghnguyen](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@trunghnguyen](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrunghnguyen)%5C
**Post date:** [October 12, 2023, 2:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F4 "2023-10-12T02:01:22Z")

</div>

hi @bilelomrani did 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.

---

<div class="post-metadata">

**Author:** ![bilelomrani](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bilelomrani/32/12193_2.png) [@bilelomrani](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbilelomrani)%5C
**Post date:** [October 17, 2023, 12:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F5 "2023-10-17T12:43:06Z")

</div>

hi @trunghnguyen, I haven’t found an idiomatic way of doing it with `transformers` unfortunately. I switched to the [curated-transformers](https://github.com/explosion/curated-transformers) library maintained by Explosion for this use case, it provides a `from_hf_hub_to_cache` method that integrated well with the HuggingFace Hub. It is exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![s4lm-xi](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@s4lm-xi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fs4lm-xi)%5C
**Post date:** [November 6, 2023, 12:23pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F6 "2023-11-06T12:23:29Z")

</div>

Hey @bilelomrani. Could you provide us the code snippet u used to download using `from_hf_hub_to_cache`

---

<div class="post-metadata">

**Author:** ![albertzeyer](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/albertzeyer/32/46906_2.png) [@albertzeyer](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Falbertzeyer)%5C
**Post date:** [May 5, 2025, 10:30am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdownloading-a-model-from-the-hub-without-loading-it%2F48377%2F7 "2025-05-05T10:30:10Z")

</div>

You can just the [CLI tool](https://huggingface.co/docs/hub/en/models-downloading):

```auto
huggingface-cli download <model_id>

```

Or via Python:

```python
from huggingface_hub import snapshot_download

snapshot_download(model_id)

```
