Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix yi template #3925

Merged
merged 1 commit into from
May 27, 2024
Merged

fix yi template #3925

merged 1 commit into from
May 27, 2024

Conversation

Yimi81
Copy link
Contributor

@Yimi81 Yimi81 commented May 27, 2024

What does this PR do?

解决yi template错误,当前yi template缺少format_system,导致sft后保存的tokenizer_config文件中chat_tempalte字段的system_prompt前后缺少|im_start|与|im_end|,这不完全符合chatml格式,而Yi系统模型采用chatml

当前SFT后tokenizer_config的chat_template值:

"chat_template": "{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ system_message }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<|im_start|>user\\n' + content + '<|im_end|>\\n<|im_start|>assistant\\n' }}{% elif message['role'] == 'assistant' %}{{ content + '<|im_end|>' + '\\n' }}{% endif %}{% endfor %}",

此PR修改后:

 "chat_template": "{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ '<|im_start|>system\\n' + system_message + '<|im_end|>\\n' }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<|im_start|>user\\n' + content + '<|im_end|>\\n<|im_start|>assistant\\n' }}{% elif message['role'] == 'assistant' %}{{ content + '<|im_end|>' + '\\n' }}{% endif %}{% endfor %}",

Before submitting

@hiyouga
Copy link
Owner

hiyouga commented May 27, 2024

LGTM!

@hiyouga hiyouga merged commit 5091248 into hiyouga:main May 27, 2024
1 check passed
@hiyouga hiyouga added the solved This problem has been already solved label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants