How to use Bertmodel?
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.
2021-05-14T13:06:16Z
You should set the environment variableTRANSFORMERS_OFFLINEto yes to be able to use a downloaded model without internet.
2021-05-14T14:41:03Z
Alternatively, if nothing has changed in recent releases, you should still be able to use the flaglocal_files_only=Truein yourfrom_pretrainedcall.
2021-05-14T15:52:03Z
Thank you, I will try in the later time
2021-05-14T15:56:10Z
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。
2021-05-15T07:50:55Z
You may want to usesentence-transformers.