Skip to content

Commit

Permalink
add chat template
Browse files Browse the repository at this point in the history
  • Loading branch information
mscheong01 committed Aug 14, 2024
1 parent 70dab0f commit cb16207
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19047,6 +19047,22 @@ static int32_t llama_chat_apply_template_internal(
if (add_ass) {
ss << "Assistant:";
}
} else if (tmpl == "exaone3" || (tmpl_contains("[|system|]") && tmpl_contains("[|assistant|]") && tmpl_contains("[|endofturn|]"))) {
// ref: https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct/discussions/8#66bae61b1893d14ee8ed85bb
// EXAONE-3.0-7.8B-Instruct
for (auto message : chat) {
std::string role(message->role);
if (role == "system") {
ss << "[|system|]" << trim(message->content) << "[|endofturn|]\n";
} else if (role == "user") {
ss << "[|user|]" << trim(message->content) << "\n";
} else if (role == "assistant") {
ss << "[|assistant|]" << trim(message->content) << "[|endofturn|]\n";
}
}
if (add_ass) {
ss << "[|assistant|]";
}
} else {
// template not supported
return -1;
Expand Down

0 comments on commit cb16207

Please sign in to comment.