8000 Support Seed-Coder chat template · makllama/llama.cpp@7320f95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7320f95

Browse files
committed
Support Seed-Coder chat template
Signed-off-by: Xiaodong Ye <xiaodong.ye@mthreads.com>
1 parent 1449214 commit 7320f95

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/llama-chat.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static const std::map<std::string, llm_chat_template> LLM_CHAT_TEMPLATES = {
6464
{ "bailing", LLM_CHAT_TEMPLATE_BAILING },
6565
{ "llama4", LLM_CHAT_TEMPLATE_LLAMA4 },
6666
{ "smolvlm", LLM_CHAT_TEMPLATE_SMOLVLM },
67+
{ "seed-coder", LLM_CHAT_TEMPLATE_SEED_CODER },
6768
};
6869

6970
llm_chat_template llm_chat_template_from_str(const std::string & name) {
@@ -183,6 +184,9 @@ llm_chat_template llm_chat_detect_template(const std::string & tmpl) {
183184
return LLM_CHAT_TEMPLATE_BAILING;
184185
} else if (tmpl_contains("<|header_start|>") && tmpl_contains("<|header_end|>")) {
185186
return LLM_CHAT_TEMPLATE_LLAMA4;
187+
} else if (tmpl_contains("raise_exception") && tmpl_contains("System role not supported") &&
188+
tmpl_contains("Conversation roles must alternate user/assistant/user/assistant/...")) {
189+
return LLM_CHAT_TEMPLATE_SEED_CODER;
186190
}
187191
return LLM_CHAT_TEMPLATE_UNKNOWN;
188192
}
@@ -643,6 +647,17 @@ int32_t llm_chat_apply_template(
643647
if (add_ass) {
644648
ss << "Assistant:";
645649
}
650+
} else if (tmpl == LLM_CHAT_TEMPLATE_SEED_CODER) {
651+
// Seed-Coder
652+
for (auto message : chat) {
653+
std::string role(message->role);
654+
if (role == "user") {
655+
ss << "<[begin▁of▁sentence]>" << role << "\n" << trim(message->content) << "<[end▁of▁sentence]>";
656+
}
657+
}
658+
if (add_ass) {
659+
ss << "<[begin▁of▁sentence]>assistant\n";
660+
}
646661
} else {
647662
// template not supported
648663
return -1;

src/llama-chat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum llm_chat_template {
4343
LLM_CHAT_TEMPLATE_BAILING,
4444
LLM_CHAT_TEMPLATE_LLAMA4,
4545
LLM_CHAT_TEMPLATE_SMOLVLM,
46+
LLM_CHAT_TEMPLATE_SEED_CODER,
4647
LLM_CHAT_TEMPLATE_UNKNOWN,
4748
};
4849

0 commit comments

Comments
 (0)
0