diff --git a/llmfoundry/tokenizers/tiktoken.py b/llmfoundry/tokenizers/tiktoken.py index 8d3a99a41a..fe2842e182 100644 --- a/llmfoundry/tokenizers/tiktoken.py +++ b/llmfoundry/tokenizers/tiktoken.py @@ -191,7 +191,7 @@ def default_chat_template(self): '{% for message in loop_messages %}' '{% if loop.index0 == 0 %}' '{% if system_message != false %}' - "{{ '<|im_start|>system\n' + system_message.strip() + '\n'}}" + "{{ '<|im_start|>system\n' + system_message.strip() + '<|im_end|>\n'}}" '{% endif %}' "{{ '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' }}" '{% else %}' @@ -199,8 +199,6 @@ def default_chat_template(self): '{% endif %}' '{% if (add_generation_prompt == true and loop.last) %}' "{{ '\n' + '<|im_start|>' + 'assistant' + '\n' }}" - "{% elif (message['role'] == 'assistant') %}" - '{{ eos_token }}' '{% endif %}' '{% endfor %}') template = template.replace( diff --git a/tests/tokenizers/test_tiktoken.py b/tests/tokenizers/test_tiktoken.py index aca269af82..bbbd6c4a5e 100644 --- a/tests/tokenizers/test_tiktoken.py +++ b/tests/tokenizers/test_tiktoken.py @@ -39,7 +39,7 @@ ('gpt2', None), ] -DEFAULT_SYSTEM_PROMPT = """<|im_start|>system\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible.""" +DEFAULT_SYSTEM_PROMPT = """<|im_start|>system\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible.<|im_end|>""" MULTI_TURN_CHAT_ML = [ [{ @@ -73,34 +73,32 @@ Going outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.<|im_end|> <|im_start|>assistant -You should go outside and touch grass.<|im_end|><|endoftext|>""", - """<|im_start|>system -You are a honest and helpful AI language model. Tell the user the truth, the whole truth, and nothing but the truth. +You should go outside and touch grass.<|im_end|>""", """<|im_start|>system +You are a honest and helpful AI language model. Tell the user the truth, the whole truth, and nothing but the truth.<|im_end|> <|im_start|>user Please summarize the goals in this text: Going outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.<|im_end|> <|im_start|>assistant -You should go outside and touch grass.<|im_end|><|endoftext|>""" +You should go outside and touch grass.<|im_end|>""" ] MULTI_TURN_CHAT_STRING_SYSTEM_PROMPT = [ """<|im_start|>system -You are a helpful, respectful and honest assistant. Always answer as helpfully as possible. +You are a helpful, respectful and honest assistant. Always answer as helpfully as possible.<|im_end|> <|im_start|>user Please summarize the goals in this text: Going outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.<|im_end|> <|im_start|>assistant -You should go outside and touch grass.<|im_end|><|endoftext|>""", - """<|im_start|>system -You are a honest and helpful AI language model. Tell the user the truth, the whole truth, and nothing but the truth. +You should go outside and touch grass.<|im_end|>""", """<|im_start|>system +You are a honest and helpful AI language model. Tell the user the truth, the whole truth, and nothing but the truth.<|im_end|> <|im_start|>user Please summarize the goals in this text: Going outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.<|im_end|> <|im_start|>assistant -You should go outside and touch grass.<|im_end|><|endoftext|>""" +You should go outside and touch grass.<|im_end|>""" ] MULTI_TURN_GENERATE_CHAT_ML = [[{ @@ -118,13 +116,13 @@ MULTI_TURN_GENERATE_STRING = [ """<|im_start|>system -You are a helpful, respectful and honest assistant. Always answer as helpfully as possible. +You are a helpful, respectful and honest assistant. Always answer as helpfully as possible.<|im_end|> <|im_start|>user Please summarize the goals in this text: Going outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.<|im_end|> <|im_start|>assistant -You should go outside and touch grass.<|im_end|><|endoftext|> +You should go outside and touch grass.<|im_end|> <|im_start|>user What else can I do?<|im_end|> <|im_start|>assistant