Add chat template for command-r model series
This commit is contained in:
parent
ab9a3240a9
commit
edb2ee4d2a
1 changed files with 15 additions and 0 deletions
15
llama.cpp
15
llama.cpp
|
@ -16476,6 +16476,21 @@ static int32_t llama_chat_apply_template_internal(
|
||||||
if (add_ass) {
|
if (add_ass) {
|
||||||
ss << "### Response:\n";
|
ss << "### Response:\n";
|
||||||
}
|
}
|
||||||
|
} else if (tmpl == "command-r" || (tmpl.find("<|START_OF_TURN_TOKEN|>") != std::string::npos && tmpl.find("<|USER_TOKEN|>") != std::string::npos)) {
|
||||||
|
// CohereForAI/c4ai-command-r-plus
|
||||||
|
for (auto message : chat) {
|
||||||
|
std::string role(message->role);
|
||||||
|
if (role == "system") {
|
||||||
|
ss << "<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>" << message->content << "<|END_OF_TURN_TOKEN|>";
|
||||||
|
} else if (role == "user") {
|
||||||
|
ss << "<|START_OF_TURN_TOKEN|><|USER_TOKEN|>" << message->content << "<|END_OF_TURN_TOKEN|>";
|
||||||
|
} else if (role == "assistant") {
|
||||||
|
ss << "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>" << message->content << "<|END_OF_TURN_TOKEN|>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (add_ass) {
|
||||||
|
ss << "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// template not supported
|
// template not supported
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue