deepseek-ai / DeepSeek-Coder

DeepSeek Coder: Let the Code Write Itself
https://coder.deepseek.com/
MIT License
6.01k stars 433 forks source link

`apply_chat_template` not works as expected #83

Closed timxx closed 6 months ago

timxx commented 6 months ago

Seems missing ### Response: for last message, take write a quick sort algorithm in python. for example, the applied template is:

<|begin▁of▁sentence|>You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer
### Instruction:
write a quick sort algorithm in python.

There is no ### Response: at the end, and the model generate is not expected as the README says.

DejianYang commented 6 months ago

transformers和tokenizers的版本是?

timxx commented 6 months ago

transformers 4.36.0 tokenizers 0.15.0

DejianYang commented 6 months ago

sorry, 我们最近由于版本更新同步更新了tokenizer 的config,需要加入add_generation_prompt=True:

>>> t.apply_chat_template([{'role': 'user', 'content': "hello" }], tokenize=False, add_generation_prompt=True)
'<|begin▁of▁sentence|>You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\n### Instruction:\nhello\n### Response:\n'