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

相关推荐
中文英文-我选中文16 小时前
FreeRTOS 玄学Bug:调换任务创建顺序,程序时而正常、时而死机(栈溢出内存踩踏深度复盘)
bug
Keven_111 天前
BUG:UVA116
算法·bug·图论
鬼手点金1 天前
opencode-隐私优先配置
服务器·前端·javascript·bug·openclaw
itmigrate3 天前
异步请求竞态,藏在页面渲染里的隐形bug
bug
今夕资源网3 天前
OmniVoice 今夕整合包 本地语音TTS断网可用 修复了一些BUG 优化生成速度 极速秒生成
bug·语音克隆·omnivoice·断网可用·本地语音tts·语音tts
烧烧的酒0.o8 天前
Codex桌面版更新后不能使用最新模型问题-排查修复总结
chatgpt·bug
sg_knight9 天前
ZCode Bug 定位实战:把报错丢给 ZCode,它是怎么修的
llm·bug·agent·ai编程·glm·智谱·zcode
轩轶子10 天前
Python CLI Todo:一次数据结构错误引发的 Bug
数据结构·python·bug
鬼手点金10 天前
Claude Code示范案例-修复 Bug 工作流
java·服务器·前端·javascript·bug·openclaw
^Rocky19 天前
IT 疑难杂症诊疗室:复杂技术问题解决实录
运维·bug