Skip to content

Commit 662192e

Browse files
authored
convert : remove unnecessary chat template patching (ggml-org#17289)
1 parent 24dc769 commit 662192e

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

convert_hf_to_gguf.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7840,12 +7840,6 @@ def set_vocab(self):
78407840
special_vocab._set_special_token("unk", tokenizer.get_added_vocab()["<|endoftext|>"]) # 151329
78417841
special_vocab._set_special_token("eom", tokenizer.get_added_vocab()["<|observation|>"]) # 151338
78427842

7843-
# Patch broken chat template
7844-
if isinstance(special_vocab.chat_template, str) and "visible_text(m.content).endswith" in special_vocab.chat_template:
7845-
special_vocab.chat_template = special_vocab.chat_template.replace(
7846-
"""{{ visible_text(m.content) }}\n{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith("/nothink")) else '' -}}""",
7847-
"""{% set content = visible_text(m.content) %}{{ content }}\n{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not content.endswith("/nothink")) else '' -}}""")
7848-
78497843
special_vocab.add_to_gguf(self.gguf_writer)
78507844

78517845
def set_gguf_parameters(self):
@@ -9395,16 +9389,6 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter
93959389
class SmolLM3Model(LlamaModel):
93969390
model_arch = gguf.MODEL_ARCH.SMOLLM3
93979391

9398-
def set_vocab(self):
9399-
super().set_vocab()
9400-
# remove unsupported array slicing in chat template
9401-
# ref: https://huggingface.co/ggml-org/SmolLM3-3B-GGUF/discussions/1
9402-
from transformers import AutoTokenizer
9403-
tokenizer = AutoTokenizer.from_pretrained(self.dir_model)
9404-
if tokenizer.chat_template is not None:
9405-
chat_template = tokenizer.chat_template.replace("[:]", "")
9406-
self.gguf_writer.add_chat_template(chat_template)
9407-
94089392

94099393
@ModelBase.register("GptOssForCausalLM")
94109394
class GptOssModel(TextModel):

0 commit comments

Comments
 (0)