]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
chat : fix kimi-k2 chat template (#14852)
authorXuan-Son Nguyen <redacted>
Thu, 24 Jul 2025 11:59:56 +0000 (13:59 +0200)
committerGitHub <redacted>
Thu, 24 Jul 2025 11:59:56 +0000 (13:59 +0200)
src/llama-arch.cpp
src/llama-chat.cpp

index 814ac93a6d87e36bfd77e7fff645cfc2db955a11..062a99776781f6146783b4670fe14df9ebde32d0 100644 (file)
@@ -1933,12 +1933,6 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> 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_arch, std::map<llm_tensor, const char *>> 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, llm_tensor_info> LLM_TENSOR_INFOS = {
index 80072ad2713c76386a1153d426a1467e946a4e3f..d34bb26878c2a971cc978cc08592974ad14b4586 100644 (file)
@@ -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