Skip to content

Commit 9099de3

Browse files
committed
Update ggml-cpu-quants.cpp
1 parent 064b689 commit 9099de3

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

ggml/src/ggml-cpu/ggml-cpu-quants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12667,7 +12667,7 @@ void ggml_vec_dot_iq4_xs_q8_K(int n, float * GGML_RESTRICT s, size_t bs, const v
1266712667

1266812668
void quantize_row_iq4_nl(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
1266912669
assert(k % QK4_NL == 0);
12670-
quantize_row_iq4_nl_ref(x, y, k);
12670+
//quantize_row_iq4_nl_ref(x, y, k);
1267112671
}
1267212672

1267312673
void quantize_row_iq4_xs(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {

src/llama-chat.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <algorithm>
88

99
#if __cplusplus >= 202000L
10-
#define LU8(x) (const char*)(u8##x)
10+
#define (x) (const char*)(u8##x)
1111
#else
1212
#define LU8(x) u8##x
1313
#endif
@@ -149,12 +149,12 @@ llm_chat_template llm_chat_detect_template(const std::string & tmpl) {
149149
return LLM_CHAT_TEMPLATE_CHATGML_3;
150150
} else if (tmpl_contains("[gMASK]<sop>")) {
151151
return LLM_CHAT_TEMPLATE_CHATGML_4;
152-
} else if (tmpl_contains(LU8("<用户>"))) {
152+
} else if (tmpl_contains(("<用户>"))) {
153153
// MiniCPM-3B-OpenHermes-2.5-v2-GGUF
154154
return LLM_CHAT_TEMPLATE_MINICPM;
155155
} else if (tmpl_contains("'Assistant: ' + message['content'] + eos_token")) {
156156
return LLM_CHAT_TEMPLATE_DEEPSEEK_2;
157-
} else if (tmpl_contains(LU8("<|Assistant|>")) && tmpl_contains(LU8("<|User|>")) && tmpl_contains(LU8("<|end▁of▁sentence|>"))) {
157+
} else if (tmpl_contains(("<|Assistant|>")) && tmpl_contains(("<|User|>")) && tmpl_contains(("<|end▁of▁sentence|>"))) {
158158
return LLM_CHAT_TEMPLATE_DEEPSEEK_3;
159159
} else if (tmpl_contains("[|system|]") && tmpl_contains("[|assistant|]") && tmpl_contains("[|endofturn|]")) {
160160
// ref: https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct/discussions/8#66bae61b1893d14ee8ed85bb
@@ -455,7 +455,7 @@ int32_t llm_chat_apply_template(
455455
for (auto message : chat) {
456456
std::string role(message->role);
457457
if (role == "user") {
458-
ss << LU8("<用户>");
458+
ss << ("<用户>");
459459
ss << trim(message->content);
460460
ss << "<AI>";
461461
} else {
@@ -471,7 +471,7 @@ int32_t llm_chat_apply_template(
471471
} else if (role == "user") {
472472
ss << "User: " << message->content << "\n\n";
473473
} else if (role == "assistant") {
474-
ss << "Assistant: " << message->content << LU8("<|end▁of▁sentence|>");
474+
ss << "Assistant: " << message->content << ("<|end▁of▁sentence|>");
475475
}
476476
}
477477
if (add_ass) {
@@ -484,13 +484,13 @@ int32_t llm_chat_apply_template(
484484
if (role == "system") {
485485
ss << message->content << "\n\n";
486486
} else if (role == "user") {
487-
ss << LU8("<|User|>") << message->content;
487+
ss << ("<|User|>") << message->content;
488488
} else if (role == "assistant") {
489-
ss << LU8("<|Assistant|>") << message->content << LU8("<|end▁of▁sentence|>");
489+
ss << ("<|Assistant|>") << message->content << ("<|end▁of▁sentence|>");
490490
}
491491
}
492492
if (add_ass) {
493-
ss << LU8("<|Assistant|>");
493+
ss << ("<|Assistant|>");
494494
}
495495
} else if (tmpl == LLM_CHAT_TEMPLATE_EXAONE_3) {
496496
// ref: https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct/discussions/8#66bae61b1893d14ee8ed85bb

tests/test-chat-template.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int main(void) {
177177
},
178178
{
179179
/* .name= */ "ChatGLM4",
180-
/* .template_str= */ u8"[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 %}",
180+
/* .template_str= */ "[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 %}",
181181
/* .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|>",
182182
/* .expected_output_jinja= */ "",
183183
/* .bos_token= */ "",
@@ -193,16 +193,16 @@ int main(void) {
193193
},
194194
{
195195
/* .name= */ "MiniCPM-3B-OpenHermes-2.5-v2-GGUF",
196-
/* .template_str= */ u8"{% for message in messages %}{% if message['role'] == 'user' %}{{'<用户>' + message['content'].strip() + '<AI>'}}{% else %}{{message['content'].strip()}}{% endif %}{% endfor %}",
197-
/* .expected_output= */ u8"You are a helpful assistant<用户>Hello<AI>Hi there<用户>Who are you<AI>I am an assistant<用户>Another question<AI>",
196+
/* .template_str= */ "{% for message in messages %}{% if message['role'] == 'user' %}{{'<用户>' + message['content'].strip() + '<AI>'}}{% else %}{{message['content'].strip()}}{% endif %}{% endfor %}",
197+
/* .expected_output= */ "You are a helpful assistant<用户>Hello<AI>Hi there<用户>Who are you<AI>I am an assistant<用户>Another question<AI>",
198198
/* .expected_output_jinja= */ "",
199199
/* .bos_token= */ "",
200200
/* .eos_token= */ "",
201201
},
202202
{
203203
/* .name= */ "DeepSeek-V2",
204204
/* .template_str= */ "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}",
205-
/* .expected_output= */ u8"You are a helpful assistant\n\nUser: Hello\n\nAssistant: Hi there<|end▁of▁sentence|>User: Who are you\n\nAssistant: I am an assistant <|end▁of▁sentence|>User: Another question\n\nAssistant:",
205+
/* .expected_output= */ "You are a helpful assistant\n\nUser: Hello\n\nAssistant: Hi there<|end▁of▁sentence|>User: Who are you\n\nAssistant: I am an assistant <|end▁of▁sentence|>User: Another question\n\nAssistant:",
206206
/* .expected_output_jinja= */ "",
207207
/* .bos_token= */ "",
208208
/* .eos_token= */ "<|end▁of▁sentence|>",
@@ -256,7 +256,7 @@ int main(void) {
256256
},
257257
{
258258
/* .name= */ "Infinigence/Megrez-3B-Instruct",
259-
/* .template_str= */ u8"{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|role_start|>system<|role_end|>你是Megrez-3B-Instruct,将针对用户的问题给出详细的、积极的回答。<|turn_end|>' }}{% endif %}{{ '<|role_start|>' + message['role'] + '<|role_end|>' + message['content'] + '<|turn_end|>' }}{% endfor %}{% if add_generation_prompt %}{{ '<|role_start|>assistant<|role_end|>' }}{% endif %}",
259+
/* .template_str= */ "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|role_start|>system<|role_end|>你是Megrez-3B-Instruct,将针对用户的问题给出详细的、积极的回答。<|turn_end|>' }}{% endif %}{{ '<|role_start|>' + message['role'] + '<|role_end|>' + message['content'] + '<|turn_end|>' }}{% endfor %}{% if add_generation_prompt %}{{ '<|role_start|>assistant<|role_end|>' }}{% endif %}",
260260
/* .expected_output= */ "<|role_start|>system<|role_end|>You are a helpful assistant<|turn_end|><|role_start|>user<|role_end|>Hello<|turn_end|><|role_start|>assistant<|role_end|>Hi there<|turn_end|><|role_start|>user<|role_end|>Who are you<|turn_end|><|role_start|>assistant<|role_end|> I am an assistant <|turn_end|><|role_start|>user<|role_end|>Another question<|turn_end|><|role_start|>assistant<|role_end|>",
261261
/* .expected_output_jinja= */ "",
262262
/* .bos_token= */ "",

0 commit comments

Comments
 (0)