mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[PR #50] [CLOSED] Add enable_thinking config option for Qwen3 and similar models #254
Labels
No labels
bug
enhancement
enhancement
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
p-e-w/heretic#254
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/p-e-w/heretic/pull/50
Author: @lbartoszcze
Created: 11/26/2025
Status: ❌ Closed
Base:
master← Head:feature/enable-thinking📝 Commits (1)
0c21adfAdd enable_thinking config option for Qwen3 and similar models📊 Changes
2 files changed (+31 additions, -4 deletions)
View changed files
📝
src/heretic/config.py(+9 -0)📝
src/heretic/model.py(+22 -4)📄 Description
Summary
Some models like Qwen3 support a "thinking mode" where the model generates internal reasoning tokens (
<think>...</think>) before the actual response. This behavior is controlled by theenable_thinkingparameter inapply_chat_template().The Problem
When abliterating these models, the thinking mode setting during training must match the intended inference setting. If the model is abliterated with thinking mode ON but used with thinking mode OFF (or vice versa), the abliteration may not transfer properly because the model's behavior differs significantly between modes.
We discovered this when abliterating Qwen3-8B - the abliteration appeared to work (refusals dropped from 43 to 37 during training), but when testing with
enable_thinking=False, the model still refused most prompts. The abliteration only worked in thinking mode because that's how it was trained.The Solution
This PR adds an
enable_thinkingconfiguration option that:False: Disables thinking mode during abliterationTrue: Enables thinking mode during abliterationNone(default): Uses the model's default behavior (backwards compatible)The setting is applied to both
generate()andstream_chat_response()methods.Usage
Changes
config.py: Addedenable_thinking: bool | Nonefield with defaultNonemodel.py: Updatedgenerate()andstream_chat_response()to passenable_thinkingtoapply_chat_template()when configuredTesting
Tested with Qwen3-4B and Qwen3-8B models. With
enable_thinking=false, the abliterated models now properly respond without refusals when used in non-thinking mode.Test plan
--enable-thinking false🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.