fix chat template bug

This commit is contained in:
toyer 2024-06-28 06:32:22 +00:00
parent 482bdeaa16
commit bbe1926fac

View file

@ -5103,6 +5103,7 @@ static void llm_load_vocab(
} else if (
tokenizer_pre == "chatglm-bpe") {
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_CHATGLM4;
vocab.special_bos_id = -1;
} else if (
tokenizer_pre == "viking") {
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_VIKING;
@ -19828,7 +19829,7 @@ static int32_t llama_chat_apply_template_internal(
if (add_ass) {
ss << "<|start_header_id|>assistant<|end_header_id|>\n\n";
}
} else if (tmpl == "chatglm3" || tmpl.find("[gMASK]sop") != std::string::npos) {
} else if (tmpl.find("chatglm3") != std::string::npos || tmpl.find("[gMASK]sop") != std::string::npos) {
// chatglm3-6b
ss << "[gMASK]" << "sop";
for (auto message : chat) {
@ -19838,7 +19839,7 @@ static int32_t llama_chat_apply_template_internal(
if (add_ass) {
ss << "<|assistant|>";
}
} else if (tmpl == "chatglm4" || tmpl.find("[gMASK]<sop>") != std::string::npos) {
} else if (tmpl.find("chatglm4") != std::string::npos || tmpl.find("[gMASK]<sop>") != std::string::npos) {
ss << "[gMASK]" << "<sop>";
for (auto message : chat) {
std::string role(message->role);