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

相关推荐
MartinYeung513 小时前
[bug 分析] Orchard 伪造漏洞: 深度代码剖析
安全·区块链·bug
为你奋斗!17 小时前
禅道Bug导出CSV文件批量转Word+图片离线部署操作手册
word·bug
隔窗听雨眠3 天前
Library Cache Lock性能故障深度解析:JDBC驱动Bug、绑定变量长度与游标激增的连环效应
bug·library
盗理者3 天前
AI Agent 工程实践|让 AI Agent 自动修 Bug:定位、修改、测试与人工审核
人工智能·bug·agent
程序员AlbertTu3 天前
Linux 系统 Bug 调试操作手册
linux·postgresql·bug
深念Y5 天前
Opencode Event 表写入优化方案
数据库·人工智能·ai·node.js·bug·优化·opencode
姚青&6 天前
Bug基本概念
bug
AI多Agent协作实战派6 天前
AI多Agent协作系统实战(三十九):AI修对了Bug,却越了权——自动化团队的第一条铁律
人工智能·自动化·bug
深念Y8 天前
AMD 芯片组驱动触发高频 SSD 写入的问题及解决方案
windows·bug·ssd·日志·芯片·驱动·amd
加油码8 天前
探秘 volatile关键字:编译器的过度优化
linux·bug·信号处理