liveBook · Manning

Chat template

A chat template is a formatting specification that converts conversational messages into the input representation expected by a language model.

How 2 Manning books explain it

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.

Read how Rearchitecting LLMs explains chat template →

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

What to know first

Related concepts

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.