运行模型后输入想要聊天机器人回复的语句后提示Warning (from warnings module): File "C:\Users\MIS_L\AppData\Roaming\Python\Python311\site-packages\transformers\generation\utils.py", line 1201 warnings.warn( UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation) 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 09:01:29 浏览: 298
VS错误提示:To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
你可以在初始化tokenizer时设置padding_side参数为left,以解决这个warning。修改的代码如下:
```
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium", padding_side="left")
```
关于使用generation configuration file进行生成,请参考https://huggingface.co/docs/transformers/main_classes/text_generation。
阅读全文