assistant_only_loss also trains the generation prompt on the Laguna templates — a one-block move in the chat template fixes it

#13
by nootxlm - opened

Hi — I was checking how the Laguna chat templates interact with assistant-only loss (the mask TRL and friends build from return_assistant_tokens_mask), and the mask starts earlier than the reply.

With a two-message probe (user asks a question, assistant answers "It is blue."), the trained span decodes to:

  • Laguna-XS.2, thinking off or on: <assistant>\n</think>\n + the reply
  • Laguna-M.1, thinking off or on: <assistant>\n</think>\n + the reply
  • Laguna-XS-2.1, thinking off: <assistant></think> + the reply; thinking on: <assistant><think></think> + the reply
  • Laguna-S-2.1: same shapes as XS-2.1

Those leading tokens are the generation prompt itself — a template render with add_generation_prompt=True ends with exactly them — so at inference the model is handed them, while in training the loss asks it to produce them.

The cause is visible in the template: the {% generation %} block opens before the <assistant> header is emitted, so everything from the header onward is marked as generated. Moving the block's opening to just before the reply content (after the header and the think scaffolding the prompt also emits) makes the trained span exactly the reply — I verified that placement on the XS-2.1 tokenizer, where the span becomes just "It is blue.".

I also wrote a small probe that runs this check against any Hub tokenizer and flags the overlap, in case it helps catch the same shape elsewhere. Happy to share it, and thanks for the models.

Sign up or log in to comment