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?
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?
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?)
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.
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.
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.
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)'
you can use it in one line:
bash <(curl -sSL https://g.bodaay.io/hfd) -m TheBloke/orca_mini_7B-GPTQ
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