Skip to content

Commit e0f572c

Browse files
matteoservangxson
andauthored
llama-chat : update GLM4 chat template (ggml-org#13238)
* update GLM4 chat template * Update chat template Co-authored-by: Xuan-Son Nguyen <[email protected]> --------- Co-authored-by: Xuan-Son Nguyen <[email protected]>
1 parent 79f26e9 commit e0f572c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/llama-chat.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ int32_t llm_chat_apply_template(
454454
ss << "<|" << role << "|>" << "\n" << message->content;
455455
}
456456
if (add_ass) {
457-
ss << "<|assistant|>";
457+
ss << "<|assistant|>\n";
458458
}
459459
} else if (tmpl == LLM_CHAT_TEMPLATE_MINICPM) {
460460
// MiniCPM-3B-OpenHermes-2.5-v2-GGUF

tests/test-chat-template.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ int main(void) {
181181
},
182182
{
183183
/* .name= */ "ChatGLM4",
184-
/* .template_str= */ U8C("[gMASK]<sop>{% for item in messages %}{% if item['tools'] is defined %}<|system|>\n你是一个名为 ChatGLM 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的,你的任务是针对用户的问题和要求提供适当的答复和支持。\n\n# 可用工具{% set tools = item['tools'] %}{% for tool in tools %}{% if tool['type'] == 'function' %}\n\n## {{ tool['function']['name'] }}\n\n{{ tool['function'] | tojson(indent=4) }}\n......{% endif %}{% endfor %}{% endif %}{% if item['content'] %}<|{{ item['role'] }}|>{{ item['metadata'] }}\n{{ item['content'] }}{% endif %}{% endfor %}{% if add_generation_prompt %}<|assistant|>{% endif %}"),
185-
/* .expected_output= */ "[gMASK]<sop><|system|>\nYou are a helpful assistant<|user|>\nHello<|assistant|>\nHi there<|user|>\nWho are you<|assistant|>\n I am an assistant <|user|>\nAnother question<|assistant|>",
184+
/* .template_str= */ U8C("[gMASK]<sop>{% for item in messages %}{% if item['tools'] is defined %}<|system|>\n你是一个名为 ChatGLM 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的,你的任务是针对用户的问题和要求提供适当的答复和支持。\n\n# 可用工具{% set tools = item['tools'] %}{% for tool in tools %}{% if tool['type'] == 'function' %}\n\n## {{ tool['function']['name'] }}\n\n{{ tool['function'] | tojson(indent=4) }}\n......{% endif %}{% endfor %}{% endif %}{% if item['content'] %}<|{{ item['role'] }}|>{{ item['metadata'] }}\n{{ item['content'] }}{% endif %}{% endfor %}{% if add_generation_prompt %}<|assistant|>\n{% endif %}"),
185+
/* .expected_output= */ "[gMASK]<sop><|system|>\nYou are a helpful assistant<|user|>\nHello<|assistant|>\nHi there<|user|>\nWho are you<|assistant|>\n I am an assistant <|user|>\nAnother question<|assistant|>\n",
186186
/* .expected_output_jinja= */ "",
187187
/* .bos_token= */ "",
188188
/* .eos_token= */ "",

0 commit comments

Comments
 (0)