Embed chat_template in tokenizer_config.json

#7
by piero-atelico - opened

What

Adds the chat template directly to tokenizer_config.json so that tokenizer.apply_chat_template() works out of the box without needing to separately download and load chat_template.jinja.

Why

Right now the chat template is only in chat_template.jinja as a separate file. The transformers library auto-loads it when it's present in the model directory, but many third-party tools and deployment pipelines only copy the standard tokenizer files (tokenizer.json + tokenizer_config.json). When the .jinja file is missing, tokenizer.chat_template is None and apply_chat_template() fails silently.

Other Gemma models (Gemma 2, Gemma 3) embed the template in tokenizer_config.json, so this seems like an oversight in the Gemma 4 release.

Related: https://github.com/huggingface/transformers/issues/45205

Closing in favor of #8 which has the actual file change.

piero-atelico changed pull request status to closed

Sign up or log in to comment