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?

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")
2 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)

1 Like