A chat template is a formatting layer that turns structured conversation data, such as system, user, and assistant messages, into the exact prompt text a model receives. It decides how roles are labeled, where separators go, and how special tokens are placed. In other words, it is the bridge between an app’s message objects and a model-ready input string.
Chat templates matter in cyber security because small changes can alter model behavior without changing the model weights. A modified template may weaken role boundaries, hide instructions, or reshape the prompt in ways that enable output hijacking or unexpected disclosure of sensitive context. Defenders should treat templates like code: pin versions, diff changes, and test the final serialized prompt before deployment. When models are loaded from shared repositories, verifying the chat template is just as important as checking the checkpoint itself.


