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 小时前
记一个 @Resource BUG
java·开发语言·bug
冬奇Lab1 天前
稳定性性能系列之四——异常日志机制与进程冻结:问题排查的黑匣子
android·性能优化·车载系统·bug
_OP_CHEN1 天前
【测试理论与实践】(三)测试BUG篇:从 BUG 本质到实战博弈,带你吃透软件测试的核心逻辑
运维·测试开发·产品运营·bug·压力测试·测试
-拟墨画扇-3 天前
Git | Bug分支操作
git·gitee·github·bug·gitcode
小凡子空白在线学习3 天前
Bug目录
bug
jiedaodezhuti4 天前
秒级定位线上Bug的一些命令
bug
l1t6 天前
修改一个触发PostgreSQL 17.2 bug的SQL
sql·postgresql·bug
包小黑6 天前
【Linux】bug登记好习惯:发现bug,用命令行截取对应日志
linux·bug
癫狂的兔子8 天前
【BUG】【Python】逆序取值为空
bug
癫狂的兔子8 天前
【BUG】【Python】精确度问题
python·bug