chat template

A template that defines how a list of conversation messages is formatted into the single text string a language model takes as input.

1 articleLast mentioned

A chat template is a template that defines how a list of conversation messages with roles such as system, user and assistant is converted into the single token string a language model receives as input. Because each model uses different role markers and special tokens, inputs must follow the same format used in training for the model to behave as expected.

Hugging Face's transformers library popularized shipping chat templates written in Jinja syntax inside the tokenizer configuration, and inference engines such as llama.cpp read the same template from GGUF files. Templates also encode constraints such as where a system message may appear and how tool calls are formatted, so a message sequence the model does not support can raise an error.

This entry is based on AIPOST articles and widely known facts. If something is wrong, please send us a correction request.

Articles covering this entry

  • Local Qwen 3.8 27B Coding Test: Four Harnesses Fix Nearly the Same BugsAI Performance ·

    Qwen 3.8's default chat template only accepts system messages at the top of the context.

    Read article

Found a mistake or missing an entry?

Wiki entries are based on AIPOST articles and widely known facts. If an entry is wrong, send us a correction request and we will check and fix it. Names from new articles are added to the wiki after the article is published.