huggingface transformer 加载gpt2报错,显式部分参数加载失败

Some weights of GPT2Model were not initialized from the model checkpoint at gpt2 and are newly initialized: [‘h.0.attn.masked_bias’, ‘h.1.attn.masked_bias’, ‘h.2.attn.masked_bias’, ‘h.3.attn.masked_bias’, ‘h.4.attn.masked_bias’, ‘h.5.attn.masked_bias’, ‘h.6.attn.masked_bias’, ‘h.7.attn.masked_bias’, ‘h.8.attn.masked_bias’, ‘h.9.attn.masked_bias’, ‘h.10.attn.masked_bias’, ‘h.11.attn.masked_bias’]
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.

transformer==4.2.1
这个个人感觉不是bug,版本可能太新了,会有这样的问题。我的话,bert ,gptlmheadmodel都是没有问题的,只有gpt2加载有问题

只需要把版本更换到2.11.0即可(如果更换的时候提示你如下libcudart.11找不到啊什么的,毫无疑问是torch你装的太新了,不要1.6+cu101或者什么的,直接降级到1.2即可)

你可能感兴趣的:(python,pytorch)