diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py index f65bac61f5..97fcd1365c 100644 --- a/unsloth/tokenizer_utils.py +++ b/unsloth/tokenizer_utils.py @@ -665,9 +665,13 @@ def _fix_chat_template(chat_template): and "<|im_start|>" in chat_template ): after_endfor = ( - "{%" + dash + " if add_generation_prompt %}" + "{%" + + dash + + " if add_generation_prompt %}" + "{{ '<|im_start|>assistant\n' }}" - + "{%" + dash + " endif %}" + + "{%" + + dash + + " endif %}" ) chat_template = chat_template[: where + len(chosen_end)] + after_endfor return chat_template