Chat template
A chat template is a formatting specification that converts conversational messages into the input representation expected by a language model.
Rearchitecting LLMs
A chat template is a formatting specification that structures messages and other content into a model's expected conversational input format.
- How it is used
- Formats conversational inputs for training and inference, including examples with structured outputs or tool calls.
- How deep it goes
- Demonstrates role-based serialization and prompt-completion construction through tokenizer calls.
- Examples
- Uses clinical-note-to-JSON training examples and Qwen3/xLAM tool-call examples.
- What you can do after
- Apply it via tokenizer.apply_chat_template to serialize messages and separate prompts from target completions.
Reinforcement Learning from Human Feedback
A chat template is a formatting specification that converts structured conversation messages into the token sequence expected by a language model.
- How it is used
- Formats conversations for instruction-tuned models and later post-training stages, including tool use.
- How deep it goes
- Explains a Jinja implementation step by step and notes model-specific differences in tool-call tokenization.
- Examples
- Uses a Jinja template, a formatted pirate-style conversation, and structured function-calling messages.
- What you can do after
- Evaluate and understand how structured messages become model-specific token streams and how an assistant response is cued.
Read how Reinforcement Learning from Human Feedback explains chat template →
Also covered in
- LLM Customization and Fine-TuningIn early access (MEAP)
- Applied Reinforcement LearningIn early access (MEAP)
What to know first
- foundation modelA foundation model is a broadly trained machine-learning model whose learned capabilities can be reused or adapted for a range of downstream tasks.
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- JSONJSON is a language-independent text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.
- deploymentDeployment is the process of placing or releasing software, models, or configuration into a target environment so they can operate there.
Related concepts
- token limitused by · A token limit is a configured upper bound on the number of tokens accepted, processed, or generated in a model operation or sequence.
- templatealternative to · A template is a reusable structure with fixed elements and variable parts for creating or organizing instances of similar content or artifacts.
Questions about chat template
What is chat template?
A chat template is a formatting specification that converts conversational messages into the input representation expected by a language model.
Which Manning books explain chat template?
Rearchitecting LLMs and Reinforcement Learning from Human Feedback.
What should I know before learning chat template?
Manning books that teach chat template usually introduce foundation model, language model, JSON and deployment first.
What is the difference between chat template and template?
A chat template is a formatting specification that converts conversational messages into the input representation expected by a language model. A template is a reusable structure with fixed elements and variable parts for creating or organizing instances of similar content or artifacts.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

