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

相关推荐
CIb0la1 小时前
Complete Bug Bounty tool List for free
linux·运维·bug
欧恩意2 小时前
【Viusal Studio】关于增量链接机制
汇编·windows·bug
Austindatabases4 小时前
SQLite 开发中的数据库开发规范 --如何提升业务系统性能避免基础BUG
数据库·oracle·sqlite·bug·数据库开发
万粉变现经纪人19 小时前
如何解决 pip install 代理报错 407 Proxy Authentication Required 问题
windows·python·pycharm·beautifulsoup·bug·pandas·pip
爱尔兰极光1 天前
软件测试--BUG篇
bug·压力测试·测试
hadage2331 天前
windows alt + tab 切换窗口时会强制把我的中文键盘的中英文输入改为中文这个bug的曲线救国方式 da
bug
烧酒同学2 天前
【Qt】QScrollArea的滑动条无法拖动(已解决)
qt·bug
黎雁·泠崖2 天前
VS2022调试通关秘籍:变量跟踪+内存分析+bug定位
c语言·bug
切糕师学AI2 天前
海森堡Bug是什么?
bug
xplidelphi2 天前
Python安装遇到的Bug
开发语言·python·bug