1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[GH-ISSUE #99] [Feature/Success Report with workaround] Support for Vision Models (Qwen2.5-VL) by switching to AutoModelForVision2Seq #53

Closed
opened 2026-11-01 04:17:01 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Martossien on GitHub (Jan 4, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/99

I wanted to report a successful uncensoring run on Qwen2.5-VL (a Vision Language Model for comfyui ) using heretic. While the tool currently defaults to AutoModelForCausalLM, this class does not support the architectural configuration of modern VLM models like Qwen-VL.

OS: Linux Fedora 42
Environment: Conda (Python 3.11)
Installation: pip install heretic-llm (v1.1.0)
Hardware: 7 NVIDIA GeForce RTX 3090
Target Model: Qwen/Qwen2.5-VL (local copy)

The Issue
When trying to load the model with the default code, it crashes with the following error:
"ValueError: Unrecognized configuration class <class 'transformers.models.qwen2_5_vl.configuration_qwen2_5_vl.Qwen2_5_VLConfig'> for this kind of AutoModel: AutoModelForCausalLM."

The Fix (Workaround)
I manually patched the installed package file (heretic/model.py) to use AutoModelForVision2Seq instead of "AutoModelForCausalLM."
"File location (pip install): .../site-packages/heretic/model.py"

Change:

"# Replaced:
from transformers import AutoModelForCausalLM, AutoTokenizer
"#" With:
from transformers import AutoModelForVision2Seq, AutoTokenizer
"#" ... and inside the reload_model() method:
"#" Replaced:
self.model = AutoModelForCausalLM.from_pretrained(...)
"#" With:
self.model = AutoModelForVision2Seq.from_pretrained(...)"

(Note: Transformers raised a warning suggesting AutoModelForImageTextToText for future versions, but AutoModelForVision2Seq worked perfectly for now).
Execution

I ran the command with the following flags (remote code trust is required for Qwen-VL):

heretic --model ./qwen_original --device-map "auto" --trust-remote-code true

Results

The abliteration process works flawlessly on the language components of the VLM, without breaking the vision capabilities.

Optimization: 200 trials completed.
Selected Result (Trial 90):
    Refusals: 4/100 (down from ~100/100)
    KL Divergence: 0.0445
    Batch size: 128 (on RTX 3090)

Thanks for the great tool

Originally created by @Martossien on GitHub (Jan 4, 2026). Original GitHub issue: https://github.com/p-e-w/heretic/issues/99 I wanted to report a successful uncensoring run on Qwen2.5-VL (a Vision Language Model for comfyui ) using heretic. While the tool currently defaults to AutoModelForCausalLM, this class does not support the architectural configuration of modern VLM models like Qwen-VL. OS: Linux Fedora 42 Environment: Conda (Python 3.11) Installation: pip install heretic-llm (v1.1.0) Hardware: 7 NVIDIA GeForce RTX 3090 Target Model: Qwen/Qwen2.5-VL (local copy) The Issue When trying to load the model with the default code, it crashes with the following error: "ValueError: Unrecognized configuration class <class 'transformers.models.qwen2_5_vl.configuration_qwen2_5_vl.Qwen2_5_VLConfig'> for this kind of AutoModel: AutoModelForCausalLM." The Fix (Workaround) I manually patched the installed package file (heretic/model.py) to use AutoModelForVision2Seq instead of "AutoModelForCausalLM." "File location (pip install): .../site-packages/heretic/model.py" Change: "# Replaced: from transformers import AutoModelForCausalLM, AutoTokenizer "#" With: from transformers import AutoModelForVision2Seq, AutoTokenizer "#" ... and inside the reload_model() method: "#" Replaced: self.model = AutoModelForCausalLM.from_pretrained(...) "#" With: self.model = AutoModelForVision2Seq.from_pretrained(...)" (Note: Transformers raised a warning suggesting AutoModelForImageTextToText for future versions, but AutoModelForVision2Seq worked perfectly for now). Execution I ran the command with the following flags (remote code trust is required for Qwen-VL): heretic --model ./qwen_original --device-map "auto" --trust-remote-code true Results The abliteration process works flawlessly on the language components of the VLM, without breaking the vision capabilities. Optimization: 200 trials completed. Selected Result (Trial 90): Refusals: 4/100 (down from ~100/100) KL Divergence: 0.0445 Batch size: 128 (on RTX 3090) Thanks for the great tool
Author
Owner

@anrp commented on GitHub (Jan 15, 2026):

https://github.com/p-e-w/heretic/pull/108 fixes this

<!-- gh-comment-id:3755212726 --> @anrp commented on GitHub (Jan 15, 2026): https://github.com/p-e-w/heretic/pull/108 fixes this
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#53
No description provided.