Using HuggingFace on no-free-internet-access server

How can I have pre-trained models from HuggingFace when I run any model on a limited server to free internet? Because it cannot download the pre-trained model parameters and then use them. Is there any way to download whatever needed for any model like BERT to my local and then transfer it to my server?

1 Like

When loading a model from pretrained, you can pass the model’s name to be obtained from Hugging Face servers, or you can pass the path of the pretrained model.

On a computer with internet access, load a pretrained model by passing the name of the model to be downloaded, then save it and move it to the computer without internet access.

model.save_pretrained("./your_file_name")

In the computer without internet access, load the pretrained model by passing the path of the file you downloaded earlier and moved here.

BertModel.from_pretrained("./your_file_name")
3 Likes

or you could also just git clone the model repo locally and move it around (and then use from_pretrained on the local directory as @SMMousavi suggests)

2 Likes

by using save_pretrained it downloads only model bin file but not the safe tensors file .

is safe tensors actually needed for inference ?