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

相关推荐
随风丶飘1 天前
[特殊字符] 告别“update“和“fix bug“——Smart Git Commit LLM 让 AI 帮你写专业的 Git 提交信息
人工智能·git·bug
czhc11400756631 天前
崩溃复查与“回声“bug:异常码判案、漏网之鱼和耳塞开关
bug
mmsx3 天前
我明明调用了 zoomToBounds,地图却总是停在别处?延迟加到 5 秒也没用,真相只有一个
android·人工智能·bug·地图
mmsx3 天前
置灰按钮为什么自己又“亮“了?一次状态缓存“双写冲突“的排查记录
java·缓存·bug·livedata
MartinYeung54 天前
[bug 分析] Orchard 伪造漏洞: 深度代码剖析
安全·区块链·bug
为你奋斗!4 天前
禅道Bug导出CSV文件批量转Word+图片离线部署操作手册
word·bug
隔窗听雨眠6 天前
Library Cache Lock性能故障深度解析:JDBC驱动Bug、绑定变量长度与游标激增的连环效应
bug·library
盗理者6 天前
AI Agent 工程实践|让 AI Agent 自动修 Bug:定位、修改、测试与人工审核
人工智能·bug·agent
程序员AlbertTu6 天前
Linux 系统 Bug 调试操作手册
linux·postgresql·bug
深念Y8 天前
Opencode Event 表写入优化方案
数据库·人工智能·ai·node.js·bug·优化·opencode