From: Xuan-Son Nguyen Date: Thu, 24 Jul 2025 11:59:56 +0000 (+0200) Subject: chat : fix kimi-k2 chat template (#14852) X-Git-Tag: upstream/0.0.6073~93 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=820de57d4faa427a3d0bfb14e48057247fae036e;p=pkg%2Fggml%2Fsources%2Fllama.cpp chat : fix kimi-k2 chat template (#14852) --- diff --git a/src/llama-arch.cpp b/src/llama-arch.cpp index 814ac93a..062a9977 100644 --- a/src/llama-arch.cpp +++ b/src/llama-arch.cpp @@ -1933,12 +1933,6 @@ static const std::map> LLM_TENSOR_N { LLM_TENSOR_TOKEN_EMBD_NORM, "token_embd_norm" }, } }, - { - LLM_ARCH_UNKNOWN, - { - { LLM_TENSOR_TOKEN_EMBD, "token_embd" }, - }, - }, { LLM_ARCH_DREAM, { @@ -1956,6 +1950,12 @@ static const std::map> LLM_TENSOR_N { LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" }, }, }, + { + LLM_ARCH_UNKNOWN, + { + { LLM_TENSOR_TOKEN_EMBD, "token_embd" }, + }, + }, }; static const std::map LLM_TENSOR_INFOS = { diff --git a/src/llama-chat.cpp b/src/llama-chat.cpp index 80072ad2..d34bb268 100644 --- a/src/llama-chat.cpp +++ b/src/llama-chat.cpp @@ -718,10 +718,9 @@ int32_t llm_chat_apply_template( } ss << message->content << "<|im_end|>"; - - if (add_ass) { - ss << "<|im_assistant|>assistant<|im_middle|>"; - } + } + if (add_ass) { + ss << "<|im_assistant|>assistant<|im_middle|>"; } } else { // template not supported