NLP_pytorch_project icon indicating copy to clipboard operation
NLP_pytorch_project copied to clipboard

Can't load weights for './bert_pretrain/pytorch_model.bin'

Open Joe-zsc opened this issue 4 years ago • 11 comments

请问这里的pytorch_model.bin是指什么,从您那下载下来的pytorch_model.bin大小只有0b

Joe-zsc avatar Jun 29 '20 07:06 Joe-zsc

在您的config.py中发现有model_path = './bert_pretrain/pytorch_model.bin',但是文件中并没有这个

Joe-zsc avatar Jun 29 '20 07:06 Joe-zsc

在您的config.py中发现有model_path = './bert_pretrain/pytorch_model.bin',但是文件中并没有这个

对呀 你需要下载 这个模型要三四百兆 所以 没上传

shawroad avatar Jun 29 '20 08:06 shawroad

在您的config.py中发现有model_path = './bert_pretrain/pytorch_model.bin',但是文件中并没有这个

对呀 你需要下载 这个模型要三四百兆 所以 没上传

请问从哪里下载啊,是bert-base-uncased这个吗,这里面没有pytorch_model.bin呀

Joe-zsc avatar Jun 29 '20 08:06 Joe-zsc

终于跑起来了 bert的预训练模型可以这样下载

from transformers import BertForMaskedLM

model = BertForMaskedLM.from_pretrained("bert-base-cased")

修改config.py的

model_path ='bert-base-cased'

Joe-zsc avatar Jun 29 '20 11:06 Joe-zsc

终于跑起来了 bert的预训练模型可以这样下载

from transformers import BertForMaskedLM

model = BertForMaskedLM.from_pretrained("bert-base-cased")

修改config.py的

model_path ='bert-base-cased'

你好,从官网下载的模型没有pytorch_model.bin,修改ckpt的文件为pytorch_model.bin仍然跑不起来,想问下你当时是怎么跑起来的

lijiayi980130 avatar Sep 26 '21 08:09 lijiayi980130

终于跑起来了 bert的预训练模型可以这样下载

from transformers import BertForMaskedLM

model = BertForMaskedLM.from_pretrained("bert-base-cased")

修改config.py的

model_path ='bert-base-cased'

你好,从官网下载的模型没有pytorch_model.bin,修改ckpt的文件为pytorch_model.bin仍然跑不起来,想问下你当时是怎么跑起来的

把你报错信息贴出来看看

shawroad avatar Sep 26 '21 09:09 shawroad

image

lijiayi980130 avatar Sep 26 '21 09:09 lijiayi980130

OK 我大概知道啥意思了。 如果我没猜错的话,你的torch版本很低。至少低于1.5

shawroad avatar Sep 26 '21 09:09 shawroad

image 没有啊,1.8.1

lijiayi980130 avatar Sep 26 '21 11:09 lijiayi980130

那可能就是模型本身转化有问题。 去下面链接 https://huggingface.co/hfl/chinese-bert-wwm-ext/tree/main 下载 pytorch_model.bin config.json vocab.txt 这几个文件。 然后放在一个文件里。 BertMode.from_pretrained('文件名') 就ok了。

shawroad avatar Sep 27 '21 01:09 shawroad

OK,谢谢啦

---Original--- From: @.> Date: Mon, Sep 27, 2021 09:27 AM To: @.>; Cc: @.@.>; Subject: Re: [shawroad/NLP_pytorch_project] Can't load weights for './bert_pretrain/pytorch_model.bin' (#31)

那可能就是模型本身转化有问题。 去下面链接 https://huggingface.co/hfl/chinese-bert-wwm-ext/tree/main下载 pytorch_model.bin config.json vocab.txt 这几个文件。 然后放在一个文件里。 BertMode.from_pretrained('文件名') 就ok了。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

lijiayi980130 avatar Sep 27 '21 02:09 lijiayi980130