How to turn English into a programming language?
Chat templates are interesting - they need to allow structured response parsing, need be specific to each model and so on.
why couldnt we settle on a universal chat template yet?
To enable structure inside unstructured English thoughts, chat templates have seen a lot of “innovation” :)
For example:
<|im_start|>system
<|im_start|>assistant
<tool_call></tool_call><|im_end|>
<|im_start|>tool
<tool_response>
...
</tool_response>
<|im_end|>
You see the pattern? The main tags are like function calls (begin-end / push-pop pairs), the first parameter attached to the call-begin tag, the end tag common across functions.
Embedded patterns are enclosed by special tags <tag>..</tag>
Chat templates are an exercise in embedding context-free grammars in readable English!