Download models for local loading
Hi,Because of some dastardly security block, I’m unable to download a model (specifically distilbert-base-uncased) through my IDE. Specifically, I’m using simpletransformers (built on top of huggingface, or at least uses its models). I tried the from_pretrained method when using huggingface directly, also, but the error is the same:OSError: Can’t load weights for ‘distilbert-base-uncased’From where can I download this pretrained model so that I can load it locally?Thanks very much,Mark
2020-11-12T13:01:06Z
You can now (since the switch to git models explained here:[Announcement] Model Versioning: Upcoming changes to the model hub) just git clone a model to your laptop and makefrom_pretrainedpoint to it:# In a google colab install git-lfs
!sudo apt-get install git-lfs
!git lfs install

# Then
!git clone https://huggingface.co/ORGANIZATION_OR_USER/MODEL_NAME

from transformers import AutoModel

model = AutoModel.from_pretrained('./MODEL_NAME')For instance:# In a google colab install git-lfs
!sudo apt-get install git-lfs
!git lfs install

# Then
!git clone https://huggingface.co/facebook/bart-base

from transformers import AutoModel

model = AutoModel.from_pretrained('./bart-base')cc@julien-cfor confirmation
2022-03-26T08:03:24Z
Hi thomwolf,But how to download only the pytorch model? I found that git cone also downloads tensorflows models, which is useless and time-comsuing for me.
2022-10-14T04:02:34Z
This works for mefrom sentence_transformers import SentenceTransformer# download pretrainedmodel = SentenceTransformer(‘bert-base-nli-mean-tokens’)# save to local directorymodel.save(“./model/”)model = None# load from local filemodel = SentenceTransformer(“./model/”)
2022-12-15T09:22:53Z
Didnt work for me with “dandelin/vilt-b32-finetuned-vqa”. Thomwolf’s solution did though.
2022-12-17T07:39:47Z
So I downloaded stable diffusion. I want to add new models, but I don’t know how to download them, at all.
2023-03-27T05:44:28Z
thomwolf:# Then
!git clone https://huggingface.co/ORGANIZATION_OR_USER/MODEL_NAMEHow can I define the revision=float16 here? Because I am trying to download the GPT-J6B model and it is around 24GB. But with revision=float16 I can get it for 12GB.How to download the 12GB version?
2023-06-22T09:34:08Z
I have followed the same steps to download mpt-7B-instruct, but when loading the model I get the following error:Error no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpackAny idea why? I have all the files from the repo, but I feel from_pretrained method is assuming I’m loading a different type of model and is looking for a different weights file.
2023-10-19T15:04:53Z
Were you able to fix this? I’m encountering similar issues
2024-01-19T12:38:53Z
I encountered the same issue because i saved the file in the wrong directory.Saving it under “C:/users/USER/.cache/huggingface/hub/” solved the issue for me!
2024-02-25T22:22:04Z
how can I download the models from huggingface directly in my specified local machine directroy rather it downloads automatically into cached location.model_id =  "meta-llama/Llama-2-7b-chat-hf"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id,
                                             device_map="auto")
2024-03-18T01:28:52Z
Themodel_idparameter can take a folder location, so if you find out where the model has been downloaded to, you can put that in instead of the model_id.So if your model was downloaded toc:/llama-chatyou would change the line to:model = AutoModelForCausalLM.from_pretrained("c:/llama-chat",                                              device_map="auto")I hope that helps.