How to resolve the 'Cannot use chat template functions...' error?

This page addresses a frequently asked question.

The "Cannot use chat template functions because tokenizer.chat_template is not set and no template argument was passed!" error usually occurs when using a model that lacks chat template support (e.g., openai-community/gpt-2). These models are not designed for structured chat interactions, causing request failures due to unsupported formatting.

To resolve this issue, ensure the local LLM server runs a model that supports chat_template. Instruct models (e.g., google/gemma-2-2b-it) can also be used, as they follow direct prompts without requiring a chat template.

Last updated

Was this helpful?