From bf3cba8a1aadd8bb190d7785ace0d1fdb0b23048 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Wed, 9 Jul 2025 01:14:31 +0200 Subject: [PATCH] convert : fix smollm3 jinja template --- convert_hf_to_gguf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/convert_hf_to_gguf.py b/convert_hf_to_gguf.py index 3f3dfb416c1fc..5d12d4799fafc 100755 --- a/convert_hf_to_gguf.py +++ b/convert_hf_to_gguf.py @@ -6692,6 +6692,16 @@ def prepare_tensors(self): class SmolLM3Model(LlamaModel): model_arch = gguf.MODEL_ARCH.SMOLLM3 + def set_vocab(self): + super().set_vocab() + # remove unsupported array slicing in chat template + # ref: https://huggingface.co/ggml-org/SmolLM3-3B-GGUF/discussions/1 + from transformers import AutoTokenizer + tokenizer = AutoTokenizer.from_pretrained(self.dir_model) + if tokenizer.chat_template is not None: + chat_template = tokenizer.chat_template.replace("[:]", "") + self.gguf_writer.add_chat_template(chat_template) + ###### CONVERSION LOGIC ######