You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The <|turn> special token in this prompt is not tokenized as <|turn> (or something similar) and instead is parsed as the special token 105. I added some debug output to llama-server to confirm this:
0.13.633.206 D srv update_slots: decoding batch, n_tokens = 11
0.13.633.207 D srv update_slots: batch token 0: 105 "<|turn>"
0.13.633.208 D srv update_slots: batch token 1: 2364 "user"
0.13.633.208 D srv update_slots: batch token 2: 107 "\n"
0.13.633.208 D srv update_slots: batch token 3: 236776 "A"
0.13.633.208 D srv update_slots: batch token 4: 105 "<|turn>"
0.13.633.209 D srv update_slots: batch token 5: 236799 "B"
0.13.633.209 D srv update_slots: batch token 6: 106 "<turn|>"
0.13.633.209 D srv update_slots: batch token 7: 107 "\n"
0.13.633.209 D srv update_slots: batch token 8: 105 "<|turn>"
0.13.633.210 D srv update_slots: batch token 9: 4368 "model"
0.13.633.210 D srv update_slots: batch token 10: 107 "\n"
This can be used to break the chat template in ways normal user input should not be able to. I am surprised that this is happening, given that common/jinja/README.md explains that the Jinja parser does taint analysis to prevent this very situation from happening.
given that common/jinja/README.md explains that the Jinja parser does taint analysis to prevent this very situation from happening.
the main issue is that this infrastructure comes after the chat.cpp was put into place, and because chat.cpp do some regex replacement for certain template, that makes the sanitation extremely tricky
nevertheless, I think I can (re-)attempt to finally wire up the jinja engine correctly in near future
Activity
ngxson commentedon Jun 9, 2026
the main issue is that this infrastructure comes after the chat.cpp was put into place, and because chat.cpp do some regex replacement for certain template, that makes the sanitation extremely tricky
nevertheless, I think I can (re-)attempt to finally wire up the jinja engine correctly in near future
github-actions commentedon Jul 25, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.
ngxson commentedon Sep 2, 2026
replaced by #28249