gpt4 book ai didi

pytorch - 为什么 GPT2Model 的一些权重没有初始化?

转载 作者:行者123 更新时间:2023-12-04 17:18:52 26 4
gpt4 key购买 nike

我正在为一个研究项目使用 GPT2 预训练模型,当我使用以下代码加载预训练模型时,

from transformers.models.gpt2.modeling_gpt2 import GPT2Model
gpt2 = GPT2Model.from_pretrained('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.

根据我的理解,它说上面层的权重不是从预训练模型初始化的。但我们都知道注意力层 ('attn') 在 GPT2 中非常重要,如果我们不能从预训练模型中获得它们的实际权重,那么使用预训练模型有什么意义?

如果有人能向我解释并告诉我如何解决这个问题,我将不胜感激。

最佳答案

添加了 masked_bias,但与原始实现相比,huggingface 社区的速度有所提高。它不应该对性能产生负面影响,因为原始权重已正确加载。检查这个PR了解更多信息。

关于pytorch - 为什么 GPT2Model 的一些权重没有初始化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67379533/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com