convert : set "add bos" == True for Gemma 4 (#21500)
* convert : set "add bos" == True for Gemma 4 * cont : handle old GGUFs
This commit is contained in:
@@ -7472,7 +7472,7 @@ class Gemma4Model(Gemma3Model):
|
|||||||
special_vocab = gguf.SpecialVocab(self.dir_model, load_merges=True)
|
special_vocab = gguf.SpecialVocab(self.dir_model, load_merges=True)
|
||||||
special_vocab.add_to_gguf(self.gguf_writer)
|
special_vocab.add_to_gguf(self.gguf_writer)
|
||||||
self.gguf_writer.add_add_space_prefix(False)
|
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):
|
def set_gguf_parameters(self):
|
||||||
super().set_gguf_parameters()
|
super().set_gguf_parameters()
|
||||||
|
|||||||
@@ -2325,6 +2325,14 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
|
|||||||
if (ml.get_key(LLM_KV_TOKENIZER_ADD_SEP, temp, false)) {
|
if (ml.get_key(LLM_KV_TOKENIZER_ADD_SEP, temp, false)) {
|
||||||
add_sep = temp;
|
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
|
// auto-detect special tokens by text
|
||||||
|
|||||||
Reference in New Issue
Block a user