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

相关推荐
中冕—霍格沃兹软件开发测试1 天前
探索性测试:思维驱动下的高效缺陷狩猎
人工智能·科技·开源·appium·bug
中冕—霍格沃兹软件开发测试1 天前
Git版本控制在测试项目管理中的应用
人工智能·git·科技·开源·appium·bug
中冕—霍格沃兹软件开发测试2 天前
用户体验测试:功能与界面并重
人工智能·科技·开源·appium·bug·ux
中冕—霍格沃兹软件开发测试2 天前
测试工具链的构建与团队协作:从工具集成到价值流动
人工智能·科技·测试工具·开源·appium·bug
yuxuan66993 天前
【Docker】使用docker启动禅道出现mysql.sock 文件已经存在的bug
mysql·docker·centos·bug
zfxwasaboy3 天前
BUG: failure at drivers/pci/msi.c:376/free_msi_irqs()!
linux·c语言·bug
yscript3 天前
GPU分配BUG: Duplicate GPU detected : rank 1 and rank 0 both on CUDA device d5000
linux·运维·服务器·vscode·bug
xiucai_cs3 天前
【后端】开发过程中如何尽可能的减少 bug 的产生
后端·bug
大江东去浪淘尽千古风流人物3 天前
【bug】bug记录学习,Win系统下爆栈的表现, chkstk.asm 实际是栈溢出
学习·bug
木棉知行者4 天前
【第2篇】RuntimeError: nms_impl: implementation for device cuda:0 not found.
人工智能·深度学习·bug·mmdetection