huggingface config_error ai_generated true

TemplateError: chat template rendering failed

ID: huggingface/chat-template-error

Also available as: JSON · Markdown
82%Fix Rate
86%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4 active

Root Cause

Chat template Jinja syntax error or missing variables.

generic

Workarounds

  1. 90% success Check tokenizer.chat_template and fix Jinja2 syntax
  2. 88% success Use tokenizer.apply_chat_template(messages, tokenize=False) to debug

Dead Ends

Common approaches that don't work:

  1. Use raw string concatenation instead of template 82% fail

    Misses special tokens

  2. Copy template from different model 78% fail

    Wrong format for this model