LLM inference in C/C++
C++ ggml
gguf-py : TemplateProcessing has final word on add_special_token (#29417)
Sigbjørn Skjæretd81aef19941e
diff --git a/conversion/nemotron.py b/conversion/nemotron.pyindex 65728d5544..c9bb3031f4 100644--- a/conversion/nemotron.py+++ b/conversion/nemotron.py@@ -424,12 +424,6 @@ class NemotronHModel(GraniteHybridModel):special_vocab = gguf.SpecialVocab(self.dir_model, load_merges=True)special_vocab.add_to_gguf(self.gguf_writer)- # The tokenizer _does_ add a BOS token (via post_processor type- # TemplateProcessing) but does not set add_bos_token to true in the- # config, so we need to explicitly override it here.- if not self.is_moe:- self.gguf_writer.add_add_bos_token(True)-_MTP_SPECIAL_RENAMES = {"mtp.layers.0.enorm.weight": "model.layers.{bid}.enorm.weight","mtp.layers.0.hnorm.weight": "model.layers.{bid}.hnorm.weight",diff --git a/gguf-py/gguf/vocab.py b/gguf-py/gguf/vocab.pyindex d93b94f2d7..b5eaa71dd2 100644--- a/gguf-py/gguf/vocab.py+++ b/gguf-py/gguf/vocab.py@@ -336,7 +336,10 @@ class SpecialVocab:for typ in self.special_token_types:add_entry = tokenizer_config.get(f'add_{typ}_token')if isinstance(add_entry, bool):- self.add_special_token[typ] = add_entry+ if typ not in self.add_special_token:+ self.add_special_token[typ] = add_entry+ elif self.add_special_token[typ] != add_entry:+ logger.warning(f'Mismatch between tokenizer_config add_{typ}_token({add_entry}) and TemplateProcessing<{typ}>({self.add_special_token[typ]}) - opting for the latter')entry = tokenizer_config.get(f'{typ}_token')if isinstance(entry, str):tc_content = entry