From 19c5a9ac12569f4edc6ef1d4f8927e974cbf0a6c Mon Sep 17 00:00:00 2001 From: Bruce Lai <55973122+bhbruce@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:57:53 +0800 Subject: [PATCH] Fix prompt format mismatch with huggingface (#807) --- models/turbine_models/custom_models/llm_runner.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/models/turbine_models/custom_models/llm_runner.py b/models/turbine_models/custom_models/llm_runner.py index d16e2250c..0188e7025 100644 --- a/models/turbine_models/custom_models/llm_runner.py +++ b/models/turbine_models/custom_models/llm_runner.py @@ -61,27 +61,25 @@ parser.add_argument( "--chat_sys_prompt", type=str, - default="""[INST] <> -Be concise. You are a helpful, respectful and honest assistant. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n <>\n\n -""", + default="""[INST] <> +Be concise. You are a helpful, respectful and honest assistant. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<>\n\n""", help="System prompt used for interactive chat mode.", ) B_INST, E_INST = "[INST]", "[/INST]" B_SYS, E_SYS = "", "" -DEFAULT_CHAT_SYS_PROMPT = """[INST] <> -Be concise. You are a helpful, respectful and honest assistant. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n <>\n\n -""" +DEFAULT_CHAT_SYS_PROMPT = """[INST] <> +Be concise. You are a helpful, respectful and honest assistant. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<>\n\n""" def append_user_prompt(history, input_prompt): - user_prompt = f"{B_INST} {input_prompt} {E_INST}" + user_prompt = f"{input_prompt} {E_INST}" history += user_prompt return history def append_bot_prompt(history, input_prompt): - user_prompt = f"{B_SYS} {input_prompt}{E_SYS} {E_SYS}" + user_prompt = f"{input_prompt} {E_SYS}{B_SYS}{B_INST}" history += user_prompt return history