try disabling the gMask prefix for glm-4 completions

This commit is contained in:
Concedo 2025-05-21 16:47:08 +08:00
parent c64557a851
commit 49305942ab
2 changed files with 24 additions and 24 deletions

View file

@ -3263,28 +3263,28 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
}
//need to add a cursed hack to get coherency for GLM4, by ensuring injection for both sop and gmask
if (file_format == FileFormat::GGUF_GENERIC && file_format_meta.model_architecture == GGUFArch::ARCH_GLM4) {
std::string temp = gpttype_get_chat_template();
if (temp.find("[gMASK]<sop>") != std::string::npos) {
if (addedmemory == "") {
if (kcpp_data->prompt.rfind("[gMASK]", 0) == 0) { //check startswith
kcpp_data->prompt.erase(0, 7);
}
if (kcpp_data->prompt.rfind("<sop>", 0) == 0) { //check startswith
kcpp_data->prompt.erase(0, 5);
}
addedmemory = "[gMASK]<sop>";
} else {
if (addedmemory.rfind("[gMASK]", 0) == 0) { //check startswith
addedmemory.erase(0, 7);
}
if (addedmemory.rfind("<sop>", 0) == 0) { //check startswith
addedmemory.erase(0, 5);
}
addedmemory = "[gMASK]<sop>" + addedmemory;
}
}
}
// if (file_format == FileFormat::GGUF_GENERIC && file_format_meta.model_architecture == GGUFArch::ARCH_GLM4) {
// std::string temp = gpttype_get_chat_template();
// if (temp.find("[gMASK]<sop>") != std::string::npos) {
// if (addedmemory == "") {
// if (kcpp_data->prompt.rfind("[gMASK]", 0) == 0) { //check startswith
// kcpp_data->prompt.erase(0, 7);
// }
// if (kcpp_data->prompt.rfind("<sop>", 0) == 0) { //check startswith
// kcpp_data->prompt.erase(0, 5);
// }
// addedmemory = "[gMASK]<sop>";
// } else {
// if (addedmemory.rfind("[gMASK]", 0) == 0) { //check startswith
// addedmemory.erase(0, 7);
// }
// if (addedmemory.rfind("<sop>", 0) == 0) { //check startswith
// addedmemory.erase(0, 5);
// }
// addedmemory = "[gMASK]<sop>" + addedmemory;
// }
// }
// }
bool stream_sse = inputs.stream_sse;
bool allow_regular_prints = (!is_quiet && debugmode!=-1);