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

相关推荐
Keven_112 天前
Bug:UVA816
bug
Keven_112 天前
Bug:UVA1103
bug
钱栈up3 天前
坯料管理导入功能bug修复:只改前端一个文件就解决问题
前端·bug
项目管理实用笔记3 天前
Bug跟踪管理系统有哪些?2026 推荐清单与选型指南
bug·研发管理·研发管理工具·项目管理软件选型
iNeuOS工业互联网6 天前
iNeuOS工业互联网操作系统,重要更新:性能优化、安全漏洞与BUG修复,远程控制响应效率大幅提升
性能优化·bug
嵌入式学习菌8 天前
Modbus‑RTU 数据类型分析
开发语言·单片机·bug
缘友一世8 天前
dsh(0.1.5-rc.1)接入官方模型deepseek-flash图像输入不支持修复
bug·图片输入·deepseek-flash·dsh 0.1.5-rc.1
lovingsoft8 天前
AI测试中的对抗测试:从“找Bug”到“预演战争”
人工智能·bug
golang学习记9 天前
VS Code 新UI被曝重大bug:菜单栏消失了
vscode·bug
j7~9 天前
【软件测试】(概念篇)《需求的概念,测试用例(case),软件错误(bug),开发模型以及测试模型》---详解
软件测试·bug·敏捷模型·开发模型·测试模型·测试中需求的定义·软件的生命周期