* convert : set "add bos" == True for Gemma 4
* cont : handle old GGUFs
special_vocab = gguf.SpecialVocab(self.dir_model, load_merges=True)
special_vocab.add_to_gguf(self.gguf_writer)
self.gguf_writer.add_add_space_prefix(False)
- self.gguf_writer.add_add_bos_token(False) # already added via the chat template
+ self.gguf_writer.add_add_bos_token(True)
def set_gguf_parameters(self):
super().set_gguf_parameters()
if (ml.get_key(LLM_KV_TOKENIZER_ADD_SEP, temp, false)) {
add_sep = temp;
}
+
+ // workaround for Gemma 4
+ // ref: https://github.com/ggml-org/llama.cpp/pull/21500
+ if (pre_type == LLAMA_VOCAB_PRE_TYPE_GEMMA4 && !add_bos) {
+ add_bos = true;
+
+ LLAMA_LOG_WARN("%s: override '%s' to 'true' for Gemma4\n", __func__, kv(LLM_KV_TOKENIZER_ADD_BOS).c_str());
+ }
}
// auto-detect special tokens by text