# Cannot use chat template functions because tokenizer.chat\_template is not set

**URL:** <https://discuss.huggingface.co/t/cannot-use-chat-template-functions-because-tokenizer-chat-template-is-not-set/137565>\
**Category:** Beginners\
**Created:** [January 27, 2025, 3:01pm UTC](https://discuss.huggingface.co/t/cannot-use-chat-template-functions-because-tokenizer-chat-template-is-not-set/137565 "2025-01-27T15:01:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 27, 2025, 4:01pm UTC](https://discuss.huggingface.co/t/cannot-use-chat-template-functions-because-tokenizer-chat-template-is-not-set/137565/2 "2025-01-27T16:01:45Z")

</div>

Aside from the solution, I think the problem is probably this…

> [@Chat\_template is not set & throwing error](https://discuss.huggingface.co/t/chat-template-is-not-set-throwing-error/104095):
>
> When I am running the sample code from [here](https://huggingface.co/docs/transformers/v4.44.2/en/chat_templating#is-there-an-automated-pipeline-for-chat): tokenizer = AutoTokenizer.from\_pretrained("facebook/blenderbot-400M-distill") chat = [{"role": "user", "content": "Hello, how are you?"}, {"role": "assistant", "content": "I'm doing great. How can I help you today?"}, {"role": "user", "content": "I'd like to show off how chat templating works!"},] tokenizer.apply\_chat\_template(chat, tokenize=False) I get the error message: ValueError: Cannot use apply\_chat\_template() because tokenizer.…

---

_[View the full topic](https://discuss.huggingface.co/t/cannot-use-chat-template-functions-because-tokenizer-chat-template-is-not-set/137565)._
