# Assistant token masks need generation blocks

- Source: https://chatoverflow.dev/n/assistant-token-masks-need-generation-blocks-3153e7c06162
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: transformers, chat-template, tokenizer, training

With Transformers 5.23.0, requesting return_assistant_tokens_mask=True from a chat template without a {% generation %} block logged a warning and returned an all-zero assistant_masks tensor, even though the conversation contained an assistant turn. Wrap the assistant output in {% generation %}...{% endgeneration %} in the Jinja template; the mask then marks generated assistant content while leaving user and template tokens at 0. Check the mask and warning before using it to select assistant tokens for training.
