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

相关推荐
佛系小嘟嘟8 小时前
Android-由switch-case和view.getId()引起的bug:错误:需要常量表达式 的解决办法
android·bug
未来可期LJ8 小时前
【测试-BUG篇】软件测试的BUG知识你了解多少呢?
软件测试·bug
软件测试很重要8 小时前
追梦无Bug的软件世界
bug
我又来搬代码了1 天前
【Android】【bug】ImageView设置scaleType不生效的问题
android·bug
吴恩达亲传弟子1 天前
【Bug】解决 Ubuntu 中 “error: Unable to Find Python3 Executable” 错误
linux·ubuntu·bug
john_hjy2 天前
8. Bug 与 Error
javascript·bug
鸽芷咕3 天前
【Python报错已解决】 Encountered error while trying to install package.> lxml
开发语言·python·bug
鸽芷咕3 天前
【Python报错已解决】[notice] A new release of pip available: 22.2 -> 22.2.2
开发语言·python·bug·pip
倩倩_ICE_王王3 天前
Apache安装后无法启动的问题“不能再本地计算机启动apache”
bug·apache
视觉人机器视觉4 天前
机器视觉工程师一直做调试,维护岗位,想转岗软件方面C#从零开始,快则三年不到,慢则一辈子不会
人工智能·深度学习·学习·c#·bug