BUG TypeError: GPT2Model.forward() got an unexpected keyword argument ‘past’

TypeError: GPT2Model.forward() got an unexpected keyword argument 'past'

环境

shell 复制代码
transformers                  4.38.1

详情

这是由于新版的transformers 对GPT2Model.forward() 参数进行了改变导致的错误。具体是past名称改为了 past_key_values

解决方法

找到错误语句,将其中的past 参数改为past_key_values

例如

python 复制代码
model = GPT2Model(config)
# 旧
transformer_outputs = model(input_ids, past=past, token_type_ids=token_type_ids)

# 新
transformer_outputs = model(input_ids, past_key_values=past, token_type_ids=token_type_ids)

参考

https://github.com/liucongg/GPT2-NewsTitle/issues/34

相关推荐
-雷阵雨-14 小时前
软件测试全解析:Bug生命周期与争议解决
bug
南林yan14 小时前
Bug: 升级内核后有线网络无法使用
bug
月巴月巴白勺合鸟月半14 小时前
一个DevExpress的Docx文件处理的Bug的解决
c#·bug
ao_lang14 小时前
软件测试-BUG篇
bug
技术小黑屋_14 小时前
Vibe Coding 真正的问题并不是 Bug
bug
利来利往14 小时前
lua table.remove引发的偶现bug
bug·lua·table.remove
haierccc18 小时前
我发现了windows的tracert命令的一个bug---ICMP重定向包详尽分析
bug
2401_841495641 天前
Windows 系统中ffmpeg安装问题的彻底解决
windows·python·ffmpeg·bug·语音识别·下载·安装步骤
gfdgd xi2 天前
GXDE 内核管理器 1.0.1——修复bug、支持loong64
android·linux·运维·python·ubuntu·bug
gfdgd xi3 天前
GXDE OS 25.2.1 更新了!引入 dtk6,修复系统 bug 若干
linux·运维·ubuntu·操作系统·bug·移植·桌面