Skip to content

[Misc] add enable_thinking to template kwargs#44817

Closed
JJJYmmm wants to merge 3 commits intohuggingface:mainfrom
JJJYmmm:main
Closed

[Misc] add enable_thinking to template kwargs#44817
JJJYmmm wants to merge 3 commits intohuggingface:mainfrom
JJJYmmm:main

Conversation

@JJJYmmm
Copy link
Copy Markdown
Contributor

@JJJYmmm JJJYmmm commented Mar 18, 2026

What does this PR do?

Fix QwenLM/Qwen3.6#97.
This PR adds enable_thinking to the chat-template kwargs. With this change, enable_thinking is treated as a template-level argument in the tokenize=True path, so it no longer leaks into processor call kwargs and triggers the “not a valid argument ... ignored” warning, while preserving existing thinking behavior.

@Rocketknight1
Copy link
Copy Markdown
Member

Ah, this is interesting! cc @zucchini-nlp, the underlying problem here is that chat templates can accept arbitrary kwargs, but we don't have a good way of filtering those arbitrary kwargs out for e.g. tokenization. We probably want a more general solution than manually adding specific template kwargs to the list, right?

@zucchini-nlp
Copy link
Copy Markdown
Member

zucchini-nlp commented Mar 19, 2026

Yep, also started noticing it after mistral4 release and pushing a proper PR today (if I have time) or tomorrow first priority. The root cause is as Matt said, because we used to call tokenizer.apply_chat_template in the past and needed to wrokaround between tokenizer vs processor kwargs

I'd prefer to not merge this PR yet

@JJJYmmm
Copy link
Copy Markdown
Contributor Author

JJJYmmm commented Mar 19, 2026

Agree! That makes sense. In my latest commit, I use jinja2.meta.find_undeclared_variables to auto-detect template kwargs, which may help with this more generally.

@github-actions
Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=44817&sha=fd3850

@zucchini-nlp
Copy link
Copy Markdown
Member

Nice way for us to detect vars and support BC, thanks

@JJJYmmm
Copy link
Copy Markdown
Contributor Author

JJJYmmm commented Mar 20, 2026

Closing this pr in favor of #44881. 🥂

@JJJYmmm JJJYmmm closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyword argument enable_thinking is not a valid argument for this processor and will be ignored

3 participants