Improve ChatML template (#5411)

This commit is contained in:
Badis Ghoubali 2024-02-05 03:39:15 +01:00 committed by GitHub
parent 2a45620c85
commit 9fdee65cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,15 +5,12 @@ instruction_template: |-
{%- set ns.found = true -%} {%- set ns.found = true -%}
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- if not ns.found -%}
{{- '<|im_start|>system\n' + '' + '<|im_end|>\n' -}}
{%- endif %}
{%- for message in messages %} {%- for message in messages %}
{%- if message['role'] == 'system' -%} {%- if message['role'] == 'system' -%}
{{- '<|im_start|>system\n' + message['content'] + '<|im_end|>\n' -}} {{- '<|im_start|>system\n' + message['content'].rstrip() + '<|im_end|>\n' -}}
{%- else -%} {%- else -%}
{%- if message['role'] == 'user' -%} {%- if message['role'] == 'user' -%}
{{-'<|im_start|>user\n' + message['content'] + '<|im_end|>\n'-}} {{-'<|im_start|>user\n' + message['content'].rstrip() + '<|im_end|>\n'-}}
{%- else -%} {%- else -%}
{{-'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' -}} {{-'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' -}}
{%- endif -%} {%- endif -%}