Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Joe-zsc opened this issue Jun 29, 2020 · 11 comments
Open

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

Joe-zsc opened this issue Jun 29, 2020 · 11 comments

Comments

@Joe-zsc
Copy link

Joe-zsc commented Jun 29, 2020

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

@Joe-zsc
Copy link
Author

Joe-zsc commented Jun 29, 2020

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

@shawroad
Copy link
Owner

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

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

@Joe-zsc
Copy link
Author

Joe-zsc commented Jun 29, 2020

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

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

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

@Joe-zsc
Copy link
Author

Joe-zsc commented Jun 29, 2020

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

from transformers import BertForMaskedLM

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

修改config.py的

model_path ='bert-base-cased'

@lijiayi980130
Copy link

终于跑起来了
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
Copy link
Owner

终于跑起来了
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
Copy link

image

@shawroad
Copy link
Owner

shawroad commented Sep 26, 2021

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

@lijiayi980130
Copy link

image
没有啊,1.8.1

@shawroad
Copy link
Owner

shawroad commented Sep 27, 2021

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

@lijiayi980130
Copy link

lijiayi980130 commented Sep 27, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants