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

相关推荐
hello_2504 天前
bug排查思路大纲
bug
秃头小饼干4 天前
关于Bug排查日记的技术文章大纲
bug
烧冻鸡翅QAQ4 天前
测试中的Bug
bug·测试
云和数据.ChenGuang6 天前
java常见SSL bug解决方案
java·bug·ssl
cat_with_cat6 天前
测试:BUG篇
bug·测试
黑客飓风6 天前
Bug排查日记的技术
bug
Wiktok6 天前
[Wit]CnOCR模型训练全流程简化记录(包括排除BUG)
python·深度学习·bug
玄尺_0076 天前
bug:uniCloud报Business Failed, 参数有误retry invoke error
数据库·bug
程序猿阿伟6 天前
《云原生边缘与AI训练场景:2类高频隐蔽Bug的深度排查与架构修复》
人工智能·云原生·bug
夕阳UPdz7 天前
深入探索 Unity 错误排查过程:从“滚动条问题”到“鼠标悬浮异常”
bug