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

相关推荐
淘矿人13 小时前
Claude辅助DevOps实践
java·大数据·运维·人工智能·算法·bug·devops
哥本哈士奇17 小时前
LangChain Deepagent 版本0.6.1中间件一个bug
中间件·langchain·bug
java修仙传1 天前
Java 实习日记:断面状态筛选 Bug 修复与对比案例日期过滤优化
java·bug·实习
CeshirenTester1 天前
当其他人回复您的帖子时是否接收实时通知? “线上Bug排查3小时,CTO当场发火”:一套让测试人“硬气”起来的质量保障体系
bug
139的世界真奇妙2 天前
生产问题排查记录
golang·bug·学习方法
oioihoii2 天前
我的第一次移动端 AI 办公:在地铁上把 Bug 修了
人工智能·bug
Coder_Shenshen2 天前
【基于LibUA库的OPC UA服务器与客户端Demo——协议解析与Bug修复实践】
网络·c#·bug
Pan Zonghui4 天前
GitHub Bug反馈与修复全流程指南
github·bug
初圣魔门首席弟子5 天前
bug 2026.05.15(以前能运行的java springboot项目突然间不能运行后台数据了)
java·开发语言·bug
Desenberg5 天前
【Claude Code】因为中途修改配置路径导致Claude Code 插件安装失败
windows·bug