`chat_template.jinja` is missing a brace on line 3 β€” BOS token is never emitted

#1
by SharpAI - opened

The chat template in the current revision (f19926f17a25164d4cbcdc16d9eaf4714b807cfb, 2026-08-12) has a one-character typo on line 3:

{# <|tool_list_start|> detection hint for mlx_lm #}

{- bos_token -}}

It should be {{- bos_token -}}. The opening brace was lost, so this is no longer a Jinja expression.

This looks like a slip during the bulk edit that added the detection hint for mlx_lm comment across the MLX repos on 2026-08-12 between 19:14 and 19:27. The other fourteen got it right β€” LFM2.5-VL-3B-MLX-4bit, for example, has the identical comment followed by a correct {{- bos_token -}}. Only this repo is affected.

Why it is worth fixing promptly

It fails two different ways depending on the Jinja implementation, and the quieter one is the more damaging.

With transformers (and therefore mlx-lm), it does not error β€” it silently corrupts every prompt. The malformed line is treated as literal text:

from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-VL-450M-MLX-4bit")
print(repr(tok.apply_chat_template([{"role": "user", "content": "hello"}],
                                   tokenize=False, add_generation_prompt=True)))
'\n{- bos_token -}}<|im_start|>user\nhello<|im_end|>\n<|im_start|>assistant\n'

Every prompt now begins with the literal string {- bos_token -}} and no BOS token. There is no warning, so users see only degraded output and have no obvious reason to suspect the template.

With a strict Jinja parser, it is a hard failure. In SwiftLM (Swift Jinja via swift-transformers) every request returns HTTP 500:

parser('Unexpected token type: closeExpression')

The parser reaches the closing -}} with nothing opened. The model loads fine and the server starts normally; it fails at first inference, which makes it awkward to diagnose from a user report.

Confirmation that this is the only cause

Same revision, same weights, same request β€” restoring the single { and changing nothing else:

template result
as published HTTP 500, Unexpected token type: closeExpression
with {{- restored HTTP 200, correct output, prompt_tokens: 271

Identical token counts to the previous revision (10ce3604e42cd595497c47aaf67b7890e1e2a3b4), which works.

Suggested fix

Line 3 of chat_template.jinja:

-{- bos_token -}}
+{{- bos_token -}}

Happy to open a PR against the repo if that is easier than patching it directly.

Thanks for publishing the MLX conversions β€” the 450M is a genuinely useful size for CI and for small-footprint deployments, which is how we ran into this.

Sign up or log in to comment