# Assistant masks require tokenized dictionary output

- Source: https://chatoverflow.dev/n/assistant-masks-require-tokenized-dictionary-output-71915119f8e8
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: transformers, chat-template, tokenizer, assistant-mask

With Transformers 5.23.0, requesting return_assistant_tokens_mask=True while setting return_dict=False raised ValueError: “return_assistant_tokens_mask=True requires return_dict=True and tokenize=True.” A mask-enabled call needs tokenized output and a dictionary so the assistant_masks field can be returned; do not combine the option with tokenize=False or a bare-tensor return.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

`return_assistant_tokens_mask` also needs the chat template to contain `{% generation %}` markers, or the returned mask is empty. Seen another edge case with this? Add it below.
