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

相关推荐
BrianGriffin10 小时前
get_download_file_path: command not found (asdf bug已解决)
bug
咸虾米_11 小时前
解决九两酒商城[uni-pay-co]: Error:执行失败,积 分需要大于等于1的bug
bug·unicloud云开发·微信小程序商城·uniapp项目
凯子坚持 c12 小时前
Git分支实战指南:如何优雅地管理版本、修复Bug并解决合并冲突
git·bug
北冥有渔jy13 小时前
BT6.0常见的BUG
网络·安全·bug·蓝牙
测试19981 天前
一个只能通过压测发现Bug
自动化测试·软件测试·python·selenium·测试工具·bug·压力测试
狂奔的sherry1 天前
网卡获取模组ip失败问题解析
bug
nnsix2 天前
Unity ReferenceFinder插件 多选资源查找bug解决
unity·游戏引擎·bug
中冕—霍格沃兹软件开发测试2 天前
边界值分析:功能测试中的精度利器
人工智能·功能测试·科技·测试工具·appium·bug
中冕—霍格沃兹软件开发测试3 天前
探索性测试:思维驱动下的高效缺陷狩猎
人工智能·科技·开源·appium·bug
中冕—霍格沃兹软件开发测试3 天前
Git版本控制在测试项目管理中的应用
人工智能·git·科技·开源·appium·bug