From d19df2c5b9647bc4f0a5cf1ece08bface5f35354 Mon Sep 17 00:00:00 2001 From: Kai Zau Date: Sat, 30 Mar 2024 09:43:47 +0900 Subject: [PATCH] Add openchat chat template --- llama.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/llama.cpp b/llama.cpp index 21e7a067a..ed7ef7e0a 100644 --- a/llama.cpp +++ b/llama.cpp @@ -15697,6 +15697,22 @@ static int32_t llama_chat_apply_template_internal( ss << message->content << ""; } } + } else if (tmpl == "openchat" || tmpl.find("GPT4 Correct ") != std::string::npos) { + // Openchat, Starling + for (auto message : chat) { + std::string role(message->role); + if (role == "user") { + ss << "GPT4 Correct User: "; + } else if (role == "assistant") { + ss << "GPT4 Correct Assistant: "; + } + // Not documented, but apparently the system message is prepended without prefix: + // https://huggingface.co/openchat/openchat_3.5/discussions/5#65448109b4a3f3a2f486fd9d + ss << message->content << "<|end_of_turn|>"; + } + if (add_ass) { + ss << "GPT4 Correct Assistant: "; + } } else { // template not supported return -1;