chat template / formatting
When you chat with an assistant, the model does not actually see tidy message bubbles. Behind the scenes the whole conversation is flattened into one long string, and special marker tokens tell the model where the system instructions end, where the user's turn begins, and where the assistant should start replying. The chat template is the recipe that inserts those markers.
Each model family has its own template — particular tokens or strings such as role headers and end-of-turn markers — and it must match the format the model was fine-tuned with. Use the wrong template and the model gets confused about whose turn it is, often rambling or answering as if it were the user. Libraries ship a template per model so your messages get assembled exactly the way training expected.
A common, maddening bug: applying one model's chat template to a different model. Always use the template that ships with the checkpoint you are running.