[GH-ISSUE #28] 关于System Prompt #17

Closed
opened 2026-10-26 21:01:40 +00:00 by bsakaguchi · 5 comments
Owner

Originally created by @DirtyKnightForVi on GitHub (Jan 9, 2024).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-LLM/issues/28

首先感谢你们的优秀开源工作!

在你们发布的技术报告中提到的System Prompt,与你们在DeepSeek coder模板中的第一句提示词接近。

不过,在你们发布的67B的chat模型中,我检查了你们发布的tokenizer_config.json,发现模板中没有位置加入这个提示词。

请问System Prompt应该是加在哪里呢?
另外你们有function call或者agent版本的模型开发计划吗?

Originally created by @DirtyKnightForVi on GitHub (Jan 9, 2024). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-LLM/issues/28 首先感谢你们的优秀开源工作! 在你们发布的技术报告中提到的System Prompt,与你们在DeepSeek coder模板中的第一句提示词接近。 不过,在你们发布的67B的chat模型中,我检查了你们发布的tokenizer_config.json,发现模板中没有位置加入这个提示词。 请问System Prompt应该是加在哪里呢? 另外你们有function call或者agent版本的模型开发计划吗?
Author
Owner

@stack-heap-overflow commented on GitHub (Jan 9, 2024):

感谢您对我们工作的关注。

实际上,我们在tokenizer_config.json的chat_template中已经预留了System Prompt的位置:

"chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}"

在使用时需要保证system消息唯一且位于第一条的位置就能得到符合我们预期的结果。

<!-- gh-comment-id:1882431397 --> @stack-heap-overflow commented on GitHub (Jan 9, 2024): 感谢您对我们工作的关注。 实际上,我们在`tokenizer_config.json`的`chat_template`中已经预留了System Prompt的位置: "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}**{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}**{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}" 在使用时需要保证system消息唯一且位于第一条的位置就能得到符合我们预期的结果。
Author
Owner

@DirtyKnightForVi commented on GitHub (Jan 9, 2024):

感谢您对我们工作的关注。

实际上,我们在tokenizer_config.json的chat_template中已经预留了System Prompt的位置:

"chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}"

在使用时需要保证system消息唯一且位于第一条的位置就能得到符合我们预期的结果。

在coder 33B这个模型上其实也有实验过:
你们的found_item参数似乎无法起作用。不管我的system是否设置了,模型还是会将默认的“you are a AI programming assistant ···”这个提示词一起输出。

虽然我也注意到你们更新了tokenizer_config.json,里面抛弃了这个参数。

<!-- gh-comment-id:1882574563 --> @DirtyKnightForVi commented on GitHub (Jan 9, 2024): > 感谢您对我们工作的关注。 > > 实际上,我们在`tokenizer_config.json`的`chat_template`中已经预留了System Prompt的位置: > > "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}**{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}**{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}" > > 在使用时需要保证system消息唯一且位于第一条的位置就能得到符合我们预期的结果。 在coder 33B这个模型上其实也有实验过: 你们的found_item参数似乎无法起作用。不管我的system是否设置了,模型还是会将默认的“you are a AI programming assistant ···”这个提示词一起输出。 虽然我也注意到你们更新了tokenizer_config.json,里面抛弃了这个参数。
Author
Owner

@stack-heap-overflow commented on GitHub (Jan 9, 2024):

在包括Tokenizer在内的部分实现细节上,chat和coder模型并不完全一致。使用不同模型时请以对应模型的chat_template为准。在chat模型中并没有默认指定System Prompt,如有需要可以自行在消息列表中添加。

<!-- gh-comment-id:1882585367 --> @stack-heap-overflow commented on GitHub (Jan 9, 2024): 在包括Tokenizer在内的部分实现细节上,chat和coder模型并不完全一致。使用不同模型时请以对应模型的`chat_template`为准。在chat模型中并没有默认指定System Prompt,如有需要可以自行在消息列表中添加。
Author
Owner

@DirtyKnightForVi commented on GitHub (Jan 9, 2024):

在包括Tokenizer在内的部分实现细节上,chat和coder模型并不完全一致。使用不同模型时请以对应模型的chat_template为准。在chat模型中并没有默认指定System Prompt,如有需要可以自行在消息列表中添加。

我的意思是:在之前coder对应的chat_template里,带了一个叫做found_item的参数,以此来控制System Prompt。
在此基础上,我发现他确实能把用户自定义的System Prompt信息带进去,但是仍然会输出你们预先设置的提示词
“you are a AI programming assistant ···”。这意味着两个system prompt。

微信图片_20240109171225

然后很遗憾,用户的这个并没有起到作用。

这应该是你们最初版本的模板:
微信图片_20240109171738

微信图片_20240109172100

按你们这个模板的话,预设的这个提示词应该不显示才对。

<!-- gh-comment-id:1882674409 --> @DirtyKnightForVi commented on GitHub (Jan 9, 2024): > 在包括Tokenizer在内的部分实现细节上,chat和coder模型并不完全一致。使用不同模型时请以对应模型的`chat_template`为准。在chat模型中并没有默认指定System Prompt,如有需要可以自行在消息列表中添加。 我的意思是:在之前coder对应的`chat_template`里,带了一个叫做`found_item`的参数,以此来控制System Prompt。 在此基础上,我发现他确实能把`用户自定义的System Prompt`信息带进去,但是仍然会输出你们预先设置的提示词 `“you are a AI programming assistant ···”`。这意味着两个system prompt。 ![微信图片_20240109171225](https://github.com/deepseek-ai/DeepSeek-LLM/assets/116725810/9f3c1742-f155-438e-aed2-ff10bcf1c68d) 然后很遗憾,用户的这个并没有起到作用。 这应该是你们最初版本的模板: ![微信图片_20240109171738](https://github.com/deepseek-ai/DeepSeek-LLM/assets/116725810/3691cf23-530a-4863-b701-378fc6786209) ![微信图片_20240109172100](https://github.com/deepseek-ai/DeepSeek-LLM/assets/116725810/23e3b97b-cf9f-4d20-b8a8-4889d4370edc) 按你们这个模板的话,预设的这个提示词应该不显示才对。
Author
Owner

@suncheng-s commented on GitHub (Oct 25, 2024):

请问,后面有找到原因吗?

<!-- gh-comment-id:2436699978 --> @suncheng-s commented on GitHub (Oct 25, 2024): 请问,后面有找到原因吗?
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-LLM#17
No description provided.