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

相关推荐
Kurbaneli2 小时前
代码诊疗室——疑难Bug破解战
bug
Mr -老鬼2 天前
从 0 到 1 落地:Rust + Salvo 实现用户系统与 Bug 管理系统
开发语言·rust·bug
剑亦未配妥2 天前
CSS 折叠引发的 scrollHeight 异常 —— 一次 Blink 引擎的诡异 Bug
前端·css·bug
gfdgd xi2 天前
GXDE OS 25.3.1 更新了!修复更多 bug 了!
linux·c++·操作系统·bug·deepin
Groundwork Explorer4 天前
wiznet5k.py硬件驱动w5500芯片网卡bug
bug
欧恩意4 天前
【BUG】Bindiff中文乱码问题
bug
系统修复专家4 天前
UG12.0官方未公开修复方法:彻底解决C++异常崩溃问题
开发语言·c++·安全·bug·dll·游戏报错
洛_尘6 天前
测试3:BUG篇
bug
蓝帆傲亦7 天前
Web前端常见Bug及排查处理方案
前端·bug
宁宁Fingerstyle7 天前
CryptoJS.AES “Malformed UTF-8 data” Bug 排查
前端·javascript·typescript·bug