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

相关推荐
木棉知行者6 小时前
【第2篇】RuntimeError: nms_impl: implementation for device cuda:0 not found.
人工智能·深度学习·bug·mmdetection
DB!!!6 小时前
【bug】系统CA证书毁坏导致找不到有效的 OpenPGP 数据
bug
中冕—霍格沃兹软件开发测试19 小时前
测试用例库建设与管理方案
数据库·人工智能·科技·开源·测试用例·bug
lvchaoq1 天前
解决组件不能远程搜索的问题
前端·bug
Vanranrr1 天前
一个由非虚函数导致的隐藏Bug:窗口显示异常问题排查与解决
开发语言·bug
AllinGold1 天前
vscode等IDE使用ssh远程连接云服务器ECS,连接不上的通常问题
bug
测试人社区—84162 天前
Postman API测试指南
人工智能·git·测试工具·自动化·bug·postman
万粉变现经纪人2 天前
如何解决 pip install 网络报错 403 Forbidden(访问被阻止)问题
数据库·python·pycharm·beautifulsoup·bug·pandas·pip
测试人社区—84162 天前
Appium移动自动化测试:从入门到精通实战
人工智能·安全·appium·自动化·bug·postman
Wokoo72 天前
软件测试分类与BUG管理
功能测试·单元测试·bug·集成测试·压力测试·ab测试