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

相关推荐
无人等人4 小时前
CyberRT(apollo) IPC(shm)通信包重复/丢包 bug 及解决方案
c++·bug
Urf_read4 小时前
改BUG:Mock测试的时候,when失效
bug
賢8434 小时前
如何保证bug在改完之后不会引起新bug
bug
永康李1 天前
Pandas:从一个DataFrame中直接索引赋值到另一个索引位置出错的Bug及其解决方案
python·bug·pandas
NPE~1 天前
Bug:Goland debug失效详细解决步骤【合集】
go·bug·goland·dlv失效
Urf_read2 天前
改BUG:远程连接redis失败,可能是防火墙的问题
java·redis·python·bug
Tlog嵌入式3 天前
单片机常见bug记录(长期更新)
单片机·嵌入式硬件·bug
会发光的猪。4 天前
el-input无法输入0.0001的小数,自动转换为0在vue3中的bug
前端·javascript·vue.js·elementui·bug
shandianchengzi4 天前
【BUG】LLM|Ubuntu 用 ollama 部署 DeepSeek 但没输出,llama 有输出
ubuntu·llm·bug·llama·ollama·deepseek
抽象具象化5 天前
Bug日记:Linux中systemctl restart network失败问题,网络故障
linux·运维·bug