mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[GH-ISSUE #2] [Feature] Transformers Quantization #1
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#1
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?
Originally created by @kabachuha on GitHub (Nov 16, 2025).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/2
Hello, p-e-w! Thank you for making this project.
Currently, this project loads the LLMs through Huggingface transformers library. This library also allows to "quantize" the models and run them in reduced precision to cut off the memory requirements dramatically.
Abliterating LLMs with quantization is absolutely possible, and I made amazing abliterated modes for myself using this abliteration repository https://github.com/Orion-zhen/abliteration, with 4bit bitsandbytes quantization enabled. The code is easy to read.
After the refusal vectors are computed from the quantized model, the model is loaded into the CPU/RAM in full precision again and the weights are modified afterwards, then the model is saved. GGUF-adaptation then can be made using the official llama.cpp scripts.
I believe it - coupled with maybe even better addition of custom device map - will be much helpful for people who don't want to rent a cloud, and thus democratize it.
Thank you for the attention to this issue.
Edit: For reference, I have successfully abliterated a finetune of LLaMA 3.3 70b on home computer with 5090+4090 in less than an hour using that repo.
@p-e-w commented on GitHub (Nov 16, 2025):
Good idea! Could you point me to a small (<= 4B parameters) quantized model on HF that I can use to experiment? I will probably have to do many runs during development, so it shouldn't be bigger than that.
@kabachuha commented on GitHub (Nov 16, 2025):
There is SmolLM from Huggingface, idk how censored it is though
https://huggingface.co/HuggingFaceTB/SmolLM-1.7B
The point is not to have it quantized right away, but to quantize it with Bitsandbytes/other quantization methods on start
For reusage, Bitsandbytes allow saving the models in quantized format, and then loading from the quants
For best quality, weights application is applied to the full precision CPU model anyway
@Chenhao-Guan commented on GitHub (Nov 17, 2025):
@p-e-w It's seems fairly easy,maybe I can help you handle with it by submitting my PR.
@p-e-w commented on GitHub (Nov 17, 2025):
@Chenhao-Guan PRs welcome!
@David-AU-github commented on GitHub (Nov 18, 2025):
This would be a fantastic addition ; 4x (4 bit) the model size to ablit ... ah... uncensor // de-refusiate ?.
I would like to suggest one more addition:
Checkpoint save[s] - either every 5-10 (user can set) and/or "intelligent" save -> certain refusal / kv level => Auto save.
Likewise auto-stop if certain refusal/kv is met.
Checkpoints are a peace of mind issue ; auto-stop (and checkpoints) are common in model tuning via Unsloth.
Another possible -> Seed value, to get re-producible runs ?
Thank you again for your excellent work.
Currently "fixing" Jan V1 4B ; one of the strongest models in 4b to 14B class.
UPDATE:
JanV1 4B (Qwen3, 256k context, thinking, convo specialized model) "abliterated" perfectly.
Ran a series (4) of 40 runs @ batch 16 (about 2 hrs each) and cherry picked the best ones.
@TomLucidor commented on GitHub (Nov 18, 2025):
If quantization is considered, can BitNet-esque acceleeration be included?
@p-e-w commented on GitHub (Dec 9, 2025):
This is implemented in #60, to be merged soon!
@p-e-w commented on GitHub (Dec 22, 2025):
#60 is now merged, resolving this issue.