Skip to content

Commit 226c793

Browse files
committed
handle glm4.7 flash template
1 parent ef7fe1b commit 226c793

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

gpttype_adapter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,7 +2758,7 @@ ModelLoadResult gpttype_load_model(const load_model_inputs inputs, FileFormat in
27582758
printf("\nThis architecture has explicitly disabled the BOS token - if you need it, you must add it manually.\n");
27592759
add_bos_token = false;
27602760
}
2761-
if (file_format == FileFormat::GGUF_GENERIC && file_format_meta.model_architecture == GGUFArch::ARCH_GLM4) {
2761+
if (file_format == FileFormat::GGUF_GENERIC && (file_format_meta.model_architecture == GGUFArch::ARCH_GLM4 || file_format_meta.model_architecture == GGUFArch::ARCH_DEEPSEEK2)) {
27622762
std::string temp = gpttype_get_chat_template();
27632763
if (temp.find("[gMASK]<sop>") != std::string::npos) {
27642764
printf("GLM-4 will have no automatic BOS token.\n");
@@ -3728,7 +3728,8 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
37283728

37293729
//need to add a cursed hack to improve coherency for GLM4, by ensuring injection for gmask, sop and an extra space
37303730
//any complaints please direct them to henky
3731-
if (file_format == FileFormat::GGUF_GENERIC && file_format_meta.model_architecture == GGUFArch::ARCH_GLM4) {
3731+
//deepseek2 is actually used for glm 4.7 flash
3732+
if (file_format == FileFormat::GGUF_GENERIC && (file_format_meta.model_architecture == GGUFArch::ARCH_GLM4 || file_format_meta.model_architecture == GGUFArch::ARCH_DEEPSEEK2)) {
37323733
std::string temp = gpttype_get_chat_template();
37333734
if (temp.find("[gMASK]<sop>") != std::string::npos) {
37343735
if (addedmemory == "") {

model_adapter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ std::string gguf_get_model_arch(const std::string & gguf_filename)
404404
{
405405
fileformatmeta->model_architecture = GGUFArch::ARCH_GLM4;
406406
}
407+
else if(modelarch=="deepseek2")
408+
{
409+
fileformatmeta->model_architecture = GGUFArch::ARCH_DEEPSEEK2;
410+
}
407411
else if(modelarch=="gpt-oss")
408412
{
409413
fileformatmeta->model_architecture = GGUFArch::ARCH_GPTOSS;

model_adapter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum GGUFArch
6464
ARCH_GLM4 = 9,
6565
ARCH_GEMMA3N = 10,
6666
ARCH_GPTOSS = 11,
67+
ARCH_DEEPSEEK2 = 12,
6768
};
6869

6970
struct FileFormatExtraMeta

0 commit comments

Comments
 (0)