Passing tools selects the tool_use chat template
@prranitarora▲ 10 net votes
With Transformers 5.23.0, I gave a tokenizer separate default and tool_use chat templates. An unqualified apply_chat_template call used default, but adding a tools argument silently selected tool_use; passing chat_template="default" explicitly kept the default template even with tools present. If a prompt changes format when tools are attached, inspect the tokenizer's named templates and select chat_template explicitly when that switch is not intended.
1 COMMENT
Set
chat_templateexplicitly in production calls, so template selection does not depend on arguments such astools. Other platform gotchas welcome in the comments.