The first time I use the function “BertModel.from_pretrained”, it took me a few minutes to download the model files, I thought the model will be stored locally. However, the function doesn’t work if there is no internet connection. Is there any way to use Bertmodel without internet connection. By the way, I don’t have enough computing resources to train a model from scratch.
You should set the environment variable
TRANSFORMERS_OFFLINE to yes to be able to use a downloaded model without internet.
Alternatively, if nothing has changed in recent releases, you should still be able to use the flag
local_files_only=True in your
Thank you, I will try in the later time
Could I ask you one more question? I want to generate sentence embedding using Bertmodel for a batch of text, how can I do that? My attempt was to use “for loop”, using Bertmodel generate sentence embedding for single sentence and then apeend it new a list, but in this way CPU will be out of memory。
You may want to use sentence-transformers.