模型已在分词器的初始化代码中添加一个参数padding_side='left',运行模型后输入想要聊天机器人回复的语句后提示A decoder-only architecture is being used, but right-padding was detected! For correct generation results, please set padding_side='left' when initializing the tokenizer. DialoGPT: Money buys happiness, but it also buys a lot of things that make you happy.需要如何修改
时间: 2023-05-27 08:01:27 浏览: 183
可以通过修改分词器的初始化代码,将padding_side参数设置为'left',以解决提示信息中的问题。具体的代码修改如下:
```
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium", pad_token_id=tokenizer.eos_token_id)
# 将padding_side参数设置为'left'
tokenizer.padding_side = 'left'
```
完成修改后,重新运行模型,即可正常进行聊天机器人回复了。
相关问题
运行模型后输入想要聊天机器人回复的语句后提示A decoder-only architecture is being used, but right-padding was detected! For correct generation results, please set padding_side='left' when initializing the tokenizer. DialoGPT: Money buys happiness, but it also buys a lot of things that make you happy.需要如何修改
这个提示意味着你的聊天机器人模型只有解码器部分,而在输入中发现了右侧填充。为了正确生成结果,请在初始化分词器时设置padding_side='left'。具体做法可以在分词器的初始化代码中添加一个参数padding_side='left',例如:tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium", padding_side='left'),这样就可以消除提示信息并进行聊天机器人的回复了。
阅读全文