From 10f508d051e27fef748c84562d07d93ee6e10281 Mon Sep 17 00:00:00 2001 From: Aaron Pham <29749331+aarnphm@users.noreply.github.com> Date: Wed, 13 Dec 2023 12:34:06 -0500 Subject: [PATCH] fix(mixtral): correct chat templates to remove additional spacing (#774) Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> --- openllm-core/src/openllm_core/config/configuration_mixtral.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openllm-core/src/openllm_core/config/configuration_mixtral.py b/openllm-core/src/openllm_core/config/configuration_mixtral.py index 8be032ac2..1c514f109 100644 --- a/openllm-core/src/openllm_core/config/configuration_mixtral.py +++ b/openllm-core/src/openllm_core/config/configuration_mixtral.py @@ -48,7 +48,7 @@ def system_message(self) -> str: @property def chat_template(self) -> str: - return repr("{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token + ' ' }}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}") + return repr("{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}") @property def chat_messages(self) -> list[MessageParam]: