fix: disable Qwen3.5 thinking mode in TRL generation#249
Merged
Conversation
Root cause of persistent garbage output: Qwen3.5-9B's chat template inserts <think> which activates internal reasoning mode. The model produces opaque thinking tokens (# # # # #) instead of DSL actions. Fix: pass enable_thinking=False to apply_chat_template. Falls back to stripping <think> from rendered text if the kwarg is not supported. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
abrichr
added a commit
that referenced
this pull request
Mar 29, 2026
Stripping <think> from rendered text was insufficient — TRL or the processor may re-apply the template, re-inserting the tags. The fix: patch processor.chat_template and processor.tokenizer.chat_template on first rollout call, removing <think>/<think> from the Jinja template itself. This ensures no code path can re-insert thinking mode. Also strips </think> (was missed in #249). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
abrichr
added a commit
that referenced
this pull request
Mar 29, 2026
Stripping <think> from rendered text was insufficient — TRL or the processor may re-apply the template, re-inserting the tags. The fix: patch processor.chat_template and processor.tokenizer.chat_template on first rollout call, removing <think>/<think> from the Jinja template itself. This ensures no code path can re-insert thinking mode. Also strips </think> (was missed in #249). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause found. Qwen3.5-9B's chat template inserts
<think>which activates internal reasoning mode. The model produces opaque thinking tokens (# # # # #) instead of DSL actions (Thought: ...\nAction: CLICK(...)).Fix: Pass
enable_thinking=Falsetoapply_chat_template. Falls back to stripping<think>from rendered text if the kwarg is not supported (older processors).This explains every TRL garbage output report — the model was in thinking mode the entire time.
Test plan
# # # #🤖 Generated with Claude Code