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

相关推荐
Bear on Toilet3 天前
3. BUG篇
bug
编程探索者小陈3 天前
【测试】之BUG篇
bug
棋宣3 天前
uni-app编译到微信小程序中,父传子props首次传递数据不接收的bug
微信小程序·uni-app·bug
wqdian_com3 天前
华为手机浏览器的一个bug
服务器·华为·bug
清水白石0084 天前
把事故变成护城河:如何设计回归测试,防止“订单重复创建”这类历史 Bug 卷土重来?
python·bug
njsgcs4 天前
c# solidworks createline 拉伸发现有微小两点间隙 导致拉伸变成薄壁特征 改bug画了6个小时 解决结果
c#·bug·solidworks
前端达人4 天前
第18课:实战案例二,线上紧急 Bug 修复全过程
bug
代钦塔拉4 天前
Qt 按钮 Lambda 信号槽重复绑定、多次触发 BUG 深度剖析与终极解决方案
c++·qt·bug
lpfasd1235 天前
Win11笔记本睡眠唤醒致命bug:NUL设备丢失致Git等工具瘫痪
git·bug
隔窗听雨眠7 天前
Git二分法精准定位Bug
git·bug·git bisect