From a1c6978ab7f421d3b8a6ca71a385ce95a6f40a0b Mon Sep 17 00:00:00 2001 From: huyiwen <1020030101@qq.com> Date: Tue, 11 Jun 2024 23:03:26 +0800 Subject: [PATCH 1/2] [fix] chat templates keep last newlines --- utilization/chat_templates.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utilization/chat_templates.py b/utilization/chat_templates.py index ec526bd7..d0605d32 100644 --- a/utilization/chat_templates.py +++ b/utilization/chat_templates.py @@ -81,6 +81,7 @@ def smart_space(parts: List[str], auto_leading_space) -> str: "assistant_start": "", "assistant_end": " [INST] ", "auto_leading_space": True, + "final_rstrip": False, "default_stops": [], }, "chatml": { @@ -91,6 +92,7 @@ def smart_space(parts: List[str], auto_leading_space) -> str: "assistant_start": "<|im_start|>assistant\n", "assistant_end": "<|im_end|>\n", "auto_leading_space": True, + "final_rstrip": False, "default_stops": ["<|im_end|>"], }, "zephyr": { @@ -101,6 +103,7 @@ def smart_space(parts: List[str], auto_leading_space) -> str: "assistant_start": "<|assistant|>\n", "assistant_end": "\n", "auto_leading_space": True, + "final_rstrip": False, "default_stops": [""], }, "phi3": { @@ -111,6 +114,7 @@ def smart_space(parts: List[str], auto_leading_space) -> str: "assistant_start": "<|assistant|>\n", "assistant_end": "<|end|>\n", "auto_leading_space": True, + "final_rstrip": False, "default_stops": ["<|end|>"], }, "llama3": { @@ -121,6 +125,7 @@ def smart_space(parts: List[str], auto_leading_space) -> str: "assistant_start": "<|start_header_id|>assistant<|end_header_id|>\n\n", "assistant_end": "<|eot_id|>", "auto_leading_space": True, + "final_rstrip": False, "default_stops": ["<|eot_id|>"], }, "alpaca": { @@ -131,6 +136,7 @@ def smart_space(parts: List[str], auto_leading_space) -> str: "assistant_start": "### Response:\n", "assistant_end": "\n\n", "auto_leading_space": True, + "final_rstrip": False, "default_stops": ["###"], } } From 65b9696031cf91c974b4b901289ad793f492de21 Mon Sep 17 00:00:00 2001 From: huyiwen <1020030101@qq.com> Date: Tue, 11 Jun 2024 23:23:51 +0800 Subject: [PATCH 2/2] [ci] fix llama2 --- tests/utilization/model/test_apply_prompt_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utilization/model/test_apply_prompt_template.py b/tests/utilization/model/test_apply_prompt_template.py index 348c12ab..4a2b6110 100644 --- a/tests/utilization/model/test_apply_prompt_template.py +++ b/tests/utilization/model/test_apply_prompt_template.py @@ -26,7 +26,7 @@ def test_llama2(conversation: Conversation): "This is a system message.\n" "<>\n" "\n" - "This is a user message. [/INST] This is an assistant message. [INST] This is the second user message. [/INST] This is the second assistant message. [INST]" + "This is a user message. [/INST] This is an assistant message. [INST] This is the second user message. [/INST] This is the second assistant message. [INST] " )