gguf-py : TemplateProcessing has final word on add_special_token (#29417)

* templateprocessing must win over tokenizer config

* remove obsolete override
This commit is contained in:
Sigbjørn Skjæret
2026-09-25 11:55:38 +02:00
committed by GitHub
parent 27b20ba8b1
commit d81aef1994
2 changed files with 4 additions and 7 deletions
-6
View File
@@ -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",
+4 -1
View File
@@ -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