Match openchat template with jinja output

This commit is contained in:
Kai Zau 2024-04-01 19:35:20 +08:00
parent 1eebfc9f0f
commit cfcbc7adf3
2 changed files with 5 additions and 8 deletions

View file

@ -15701,14 +15701,11 @@ static int32_t llama_chat_apply_template_internal(
// openchat/openchat-3.5-0106,
for (auto message : chat) {
std::string role(message->role);
if (role == "user") {
ss << "GPT4 Correct User: ";
} else if (role == "assistant") {
ss << "GPT4 Correct Assistant: ";
if (message == chat.front()) {
ss << "<s>";
}
// 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|>";
role[0] = toupper(role[0]);
ss << "GPT4 Correct " << role << ": " << message->content << "<|end_of_turn|>";
}
if (add_ass) {
ss << "GPT4 Correct Assistant:";

View file

@ -60,7 +60,7 @@ int main(void) {
// OrionStarAI/Orion-14B-Chat
"Human: You are a helpful assistant\n\nHello\n\nAssistant: </s>Hi there</s>Human: Who are you\n\nAssistant: </s> I am an assistant </s>Human: Another question\n\nAssistant: </s>",
// openchat/openchat-3.5-0106
"You are a helpful assistant<|end_of_turn|>GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant: Hi there<|end_of_turn|>GPT4 Correct User: Who are you<|end_of_turn|>GPT4 Correct Assistant: I am an assistant <|end_of_turn|>GPT4 Correct User: Another question<|end_of_turn|>GPT4 Correct Assistant:",
"<s>GPT4 Correct System: You are a helpful assistant<|end_of_turn|>GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant: Hi there<|end_of_turn|>GPT4 Correct User: Who are you<|end_of_turn|>GPT4 Correct Assistant: I am an assistant <|end_of_turn|>GPT4 Correct User: Another question<|end_of_turn|>GPT4 Correct Assistant:",
// eachadea/vicuna-13b-1.1
"You are a helpful assistant\n\nUSER: Hello\nASSISTANT: Hi there</s>\nUSER: Who are you\nASSISTANT: I am an assistant </s>\nUSER: Another question\nASSISTANT:",
// Orca-Vicuna