mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 00:54:41 +00:00
cursed hack for glm4, may or may not be better
This commit is contained in:
parent
8bd6f9f9ae
commit
69b5d4d4af
1 changed files with 31 additions and 0 deletions
|
@ -3256,6 +3256,37 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
|
|||
}
|
||||
}
|
||||
|
||||
//need to add a cursed hack to improve coherency for GLM4, by ensuring injection for gmask, sop and an extra space
|
||||
//any complaints please direct them to henky
|
||||
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.empty() && kcpp_data->prompt.rfind("[gMASK]", 0) == 0) { //check startswith
|
||||
kcpp_data->prompt.erase(0, 7);
|
||||
}
|
||||
if (!kcpp_data->prompt.empty() && kcpp_data->prompt.rfind("<sop>", 0) == 0) { //check startswith
|
||||
kcpp_data->prompt.erase(0, 5);
|
||||
}
|
||||
if (!kcpp_data->prompt.empty() && kcpp_data->prompt[0] == ' ') { // check for leading space
|
||||
kcpp_data->prompt.erase(0, 1);
|
||||
}
|
||||
addedmemory = "[gMASK]<sop> ";
|
||||
} else {
|
||||
if (!addedmemory.empty() && addedmemory.rfind("[gMASK]", 0) == 0) { //check startswith
|
||||
addedmemory.erase(0, 7);
|
||||
}
|
||||
if (!addedmemory.empty() && addedmemory.rfind("<sop>", 0) == 0) { //check startswith
|
||||
addedmemory.erase(0, 5);
|
||||
}
|
||||
if (!addedmemory.empty() && addedmemory[0] == ' ') { // check for leading space
|
||||
addedmemory.erase(0, 1);
|
||||
}
|
||||
addedmemory = "[gMASK]<sop> " + addedmemory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool stream_sse = inputs.stream_sse;
|
||||
bool allow_regular_prints = (!is_quiet && debugmode!=-1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue