# Chat template

> Chat template: The model-specific rule that turns a list of role-tagged messages into the one token sequence the model was fine-tuned on, with special…

Canonical: https://llmdojo.dev/glossary/chat-template

Also called chat templates.

The model-specific rule that turns a list of role-tagged messages into the one token sequence the model was fine-tuned on, with special markers around each turn. A wrong template fails silently.

Learn it in the lesson: [A chat is one token sequence](https://llmdojo.dev/learn/prompt-context-engineering/prompt-anatomy/chat-templates) (Prompt and Context Engineering · Anatomy of a Prompt: Roles, Templates and Instruction Hierarchy).

## Interview questions about Chat template

- [You send a chat API a system message and a user message. What does the model actually receive, and why might the system prompt carry more weight?](https://llmdojo.dev/interview/q/you-send-a-chat-api-a-system-message-and-a-user-message)
- [After a library upgrade, your self-hosted Llama 3 gives worse answers and no errors. How do you debug it?](https://llmdojo.dev/interview/q/after-a-library-upgrade-your-self-hosted-llama-3-gives-worse-answers)
- [You're handed fine-tuning code whose loss behaves oddly. What do you check?](https://llmdojo.dev/interview/q/you-re-handed-fine-tuning-code-whose-loss-behaves-oddly-what-do)

## Related
- [System prompt](https://llmdojo.dev/glossary/system-prompt)
- [Instruction hierarchy](https://llmdojo.dev/glossary/instruction-hierarchy)
- [Glossary of every term](https://llmdojo.dev/glossary)
