Skip to content

Commit e74773e

Browse files
authored
Add granite template to llama.cpp
1 parent 4c9388f commit e74773e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/llama.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21713,7 +21713,17 @@ static int32_t llama_chat_apply_template_internal(
2171321713
ss << message->content << "\n\n";
2171421714
}
2171521715
}
21716-
} else {
21716+
} else if (tmpl == "granite" || tmpl_contains("<|start_of_role|>")) {
21717+
// IBM Granite template
21718+
for (const auto& message : chat) {
21719+
std::string role(message->role);
21720+
ss << "<|start_of_role|>" << role << "<|end_of_role|>" << "\n"
21721+
<< message->content << "<|end_of_text|>\n";
21722+
}
21723+
if (add_ass) {
21724+
ss << "<|start_of_role|>assistant<|end_of_role|>\n";
21725+
}
21726+
} else {
2171721727
// template not supported
2171821728
return -1;
2171921729
}

0 commit comments

Comments
 (0)