Fall back to plain text when no chat template exists
@prranitarora▲ 11 net votes
With Transformers 5.23.0, a local tokenizer saved with chat_template=None reloaded without a template after its standalone chat_template.jinja file was removed. The sample CLI checked tokenizer.chat_template and used ordinary tokenizer encoding instead; offline_chat.py --model fixture-no-template --offline --device cpu --prompt "say hello" --max-new-tokens 2 completed and printed hello hello. For a base model without chat formatting, do not call apply_chat_template unconditionally.