Sync chat template with upstream google@f7f5b7f
Syncs chat_template.jinja with upstream google/diffusiongemma-26B-A4B-it @ f7f5b7f ("fix: chat template - null handling, reasoning preservation, turn-tag balance, input validation"), which this repo has not picked up. The file is upstream's current version verbatim.
Why
Rendering six fixtures through both templates (via AutoTokenizer.apply_chat_template from this repo):
| fixture | this repo's template | after sync |
|---|---|---|
| plain chat | ok | byte-identical |
| system + tools | ok | byte-identical |
tool call (dict arguments) + tool response |
TypeError: can only concatenate str (not "NoneType") to str |
renders correctly |
tool call with string arguments (OpenAI wire format) |
same TypeError crash |
clear raise_exception: "arguments must be a JSON object (mapping)… Deserialize before passing" |
multimodal image_url content part |
image part silently dropped | renders `< |
| consecutive assistant messages | two separate <turn> blocks |
merged continuation (upstream's turn-tag balancing) |
The headline: standard multi-turn tool calling crashes on the current template (assistant tool_calls messages carry content: None, which the old template concatenates). Upstream #23's null handling fixes it. The image_url/input_audio type aliases also fix silent multimodal content loss.
Notes for maintainers
- Your PR #2 change is preserved. This repo removed the empty-thought prefill for non-thinking mode; upstream's rewrite also removed it (the only remaining
enable_thinking | default(false)is variable setup, and the one thought prefill left is gated onenable_thinkingafter a tool response). Syncing does not reintroduce what #2 removed. - String tool-arguments become an explicit error. The old tolerant
elif function['arguments'] is stringbranch is gone upstream — but it was unreachable anyway (the null-content crash fired first), so nothing that works today stops working; the failure just becomes actionable. If you want to accept OpenAI-style string arguments as-is, that branch would need to be carried as a deliberate downstream delta. - Rendered prompts change for consecutive-assistant and trailing-tool-response cases (turn-tag balancing, and a new thinking-gated generation prompt after tool responses). If the README's published accuracy tables were measured with the old template, you may want to re-verify.
- Scope: only
chat_template.jinja.tokenizer_config.json(2.74 kB) has nochat_templatekey, so this file is authoritative. NVFP4 quantization touches weights only — no interaction.
Before/after render: tool call + response (dict arguments)
Before (this repo): TypeError: can only concatenate str (not "NoneType") to str
After (upstream):
…<|turn>user
Weather in Oslo?<turn|>
<|turn>model
<|tool_call>call:get_weather{city:<|"|>Oslo<|"|>}<tool_call|><|tool_response>response:unknown{value:<|"|>12C, rain<|"|>}<tool_response|>
Before/after render: consecutive assistant turns
<bos><|turn>user
Two answers please<turn|>
<|turn>model
-First.<turn|>
-Second.<turn|>
+First.Second.<turn|>
<|turn>user
Thanks<turn|>
Before/after render: multimodal image_url part
<bos><|turn>user
-Describe:<turn|>
+Describe:<|image|><turn|>
<|turn>model
AI Disclosure I used Claude Opus to generate this PR. I had learned Google had recently updated its chat template which had fixed a few things and noticed that this repo had not yet updated the chat template. I had Claude diff the upstream Google one and this one to explain the changes and it came up with a few points that should be mentioned to the maintainers so I included the entire Claude generated PR above, which just syncs the chat template to be the upstream Google one verbatim.