How-to-use-Transformers icon indicating copy to clipboard operation
How-to-use-Transformers copied to clipboard

如何基于transformers库自定义模型?

Open blue-vision0 opened this issue 1 year ago • 1 comments

image 我试了一下您这个写法,确实可以从from_pretrained方法中加载一些已经预训练过的一些模型,但是前提是这个地方的参数名称一定叫做self.bert 如果我把这一行的名称改写为self.bert_model等等其他的名称,就统统无法用from_pretrained方法成功加载权重了。这样是不是太死板了,有什么别的方法解决吗?

blue-vision0 avatar Jan 30 '24 07:01 blue-vision0

Really? Why rename can make mistake? I have recurrented your code and there is no error. Check out if you have any other problems

Melmaphother avatar Mar 25 '24 13:03 Melmaphother

同,我也发现了这个问题,很神奇

QXGeraldMo avatar Feb 07 '25 03:02 QXGeraldMo

Really? Why rename can make mistake? I have recurrented your code and there is no error. Check out if you have any other problems

Maybe it has something to do with the transformer package version, if you don`t encounter any error while loading weight which version do you use?

blue-vision0 avatar Feb 07 '25 03:02 blue-vision0