28
https://huggingface.co/models

For example, I want to download 'bert-base-uncased', but cann't find a 'Download' link. Please help. Or is it not downloadable?

marlon
  • 6,029
  • 8
  • 42
  • 76

7 Answers7

49

Accepted answer is good, but writing code to download model is not always convenient. It seems git works fine with getting models from huggingface. Here is an example:

git lfs clone https://huggingface.co/sberbank-ai/ruT5-base

where 'lfs' stays for 'large file storage'. Technically this command is deprecated and simple 'git clone' should work, but then you need to setup filters to not skip large files (How do I clone a repository that includes Git LFS files?)

Jahjajaka
  • 839
  • 1
  • 7
  • 9
  • 1
    Just use `git clone `. git has started to throw warning of deprecation. `WARNING: 'git lfs clone' is deprecated and will not be updated with new flags from 'git clone' \n 'git clone' has been updated in upstream Git to have comparable speeds to 'git lfs clone'.` – Anurag Dhadse Feb 16 '23 at 11:01
  • Just for everyone like me with the same problem, check here (https://git-lfs.com/) and download the archive (e.g.: "https://github.com/git-lfs/git-lfs/releases/download/v3.3.0/git-lfs-linux-amd64-v3.3.0.tar.gz"). Inside its `install.sh` file set `prefix="${HOME}/.local"` as path where the `install.sh` will find the bin folder to put the `git-lfs` binary. Save it and run the script with `sh ./install.sh` as current user. Once this is done you can use the command `git-lfs clone https://huggingface.co/sberbank-ai/ruT5-base` to clone the repository on huggingface.co – Riccardo Volpe Mar 29 '23 at 00:47
14

I aggre with Jahjajaka's answer. In addition, you can find the git url by clicking the button called "Use in Transformers", shown in the picture. clicking the button called "Use in Transformers"

S.Fan
  • 151
  • 1
  • 4
11

The models are automatically cached locally when you first use it. So, to download a model, all you have to do is run the code that is provided in the model card (I chose the corresponding model card for bert-base-uncased).

At the top right of the page you can find a button called "Use in Transformers", which even gives you the sample code, showing you how to use it in Python. Again, for bert-base-uncased, this gives you the following code snippet:

from transformers import AutoTokenizer, AutoModelForMaskedLM
  
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
model = AutoModelForMaskedLM.from_pretrained("bert-base-uncased")

When you run this code for the first time, you will see a download bar appear on screen. See this post (disclaimer: I gave one of the answers) if you want to find the actual folder where Huggingface stores their models.

dennlinger
  • 9,890
  • 1
  • 42
  • 63
3

I typically see if the model has a GitHub repo where I can download the zip file. Due to my company protocols I often cannot directly connect to some sources without getting an SSL certificate error, but I can download from GitHub.

JCM
  • 365
  • 1
  • 2
  • 15
3

How about using hf_hub_download from huggingface_hub library?

hf_hub_download returns the local path where the model was downloaded so you could hook this one liner with another shell command.

python3 -c 'from huggingface_hub import hf_hub_download; downloaded_model_path = hf_hub_download(
                                                          repo_id="CompVis/stable-diffusion-v-1-4-original",
                                                          filename="sd-v1-4.ckpt",
                                                          use_auth_token=True
                                                         ); print(downloaded_model_path)'
Oscar Nevarez
  • 994
  • 12
  • 24
0

HuggingFaceModelDownloader

you can use it in one line:

bash <(curl -sSL https://g.bodaay.io/hfd) -m TheBloke/orca_mini_7B-GPTQ
bodaay
  • 1
  • 1
    Can you rewrite the command without the link to a 3rd party site, even it makes it multi-step (and it'd also be good to disclose yourself as the author); even better if it showed downloading 'bert-base-uncased' in OP. The problem is that this currently looks like a hacker script, and your low-rep doesn't help. – Darren Cook Jul 26 '23 at 11:13
  • By the link you seem to be an author. You must disclose your affiliation in your answer. See [How not to be a spammer](/help/promotion). – user16217248 Aug 27 '23 at 00:25
0

Hover over the boxy lfs icon to get the download link.

curl -L https://huggingface.co/TheBloke/falcon-7b-instruct-GGML/resolve/main/falcon-7b-instruct.ggccv1.q4_1.bin --output falcon-7b-instruct.ggccv1.q4_1.bin
patrick
  • 16,091
  • 29
  • 100
  • 164