Abliteration HandbookField guide
Technique atlas

LoRA & QLoRA abliteration techniques

Low-rank and quantized-low-rank methods for refusal removal on small GPUs and adapter-only deployment. Distinct from generic QLoRA fine-tuning on uncensored chat data — these techniques…

3 min read 7 examples Source-linked

In this chapter
On this page Interactive companion
Personal reading progress

0/10 sections reviewed

View original Markdown
Interactive companion

Explore the chapter map

Use the visual controls alongside the complete source chapter.

Low-rank and quantized-low-rank methods for refusal removal on small GPUs and adapter-only deployment. Distinct from generic QLoRA fine-tuning on uncensored chat data — these techniques target the refusal direction structurally.


Technique map#

#TechniqueAlters base weights?VRAMOutput size
1Heretic bnb_4bitYes (merged)LowFull checkpoint
2Heretic row_normalization = full + LoRA rankYes (+ tiny LoRA tensors)Low–medFull + optional LoRA sidecar
3llm-abliteration --quant 4bit measureYes (sharded)LowFull checkpoint
4ΔW low-rank export (PEFT)No (adapter)Low inferMB-scale adapter
5QLoRA refusal-steer trainingNo (adapter)LowAdapter (different mechanism)
6Inference hook onlyNoLowestdirection.pt only

1. QLoRA-style loading for abliteration (measure & optimize)#

Not training — load the base model in 4-bit so forward passes for direction estimation and Optuna fit in VRAM.

Heretic#

toml
quantization = "bnb_4bit"
offload_outputs_to_cpu = true

llm-abliteration#

bash
python measure.py -m <model> -o directions.pt --quant 4bit

Mechanism: bitsandbytes NF4 (or similar) stores weights compressed; activations still need headroom. Pair with CPU offload for residuals.

Trade-off: Optimizer explores ablation parameters on a quantized weight view; final export is still a full-precision (or configured dtype) checkpoint. Always run KL/refusal eval — if drift is high, re-run measure in FP16 on a layer subset.

→ ../instructions/low-vram-abliteration.md


2. Heretic norm-preserving LoRA (built-in)#

From Heretic config.default.toml:

toml
row_normalization = "full"   # "none" | "pre" | "full"
full_normalization_lora_rank = 3

When orthogonalizing o_proj / down_proj, row magnitudes change non-linearly. Heretic approximates magnitude restoration with a rank-r LoRA correction bundled in the export.

row_normalizationBehavior
noneRaw orthogonalization
preLoRA computed vs row-normalized weights
fullLike pre, then renormalize rows (best KL in practice)

Tuning full_normalization_lora_rank:

RankUse
3Default; smallest files
8–16If capability metrics drop after abliteration
32+Rare; diminishing returns, larger shards

This is structural LoRA from abliteration math, not SGD fine-tuning.


3. LoRA adapter as the deliverable (ΔW factorization)#

Goal: Keep the original base model unchanged; ship adapter_model.safetensors (~10–200 MB).

Pipeline#

Example
1. Abliterate (Heretic or manual) → W'
2. ΔW = W' - W  per target module (o_proj, down_proj)
3. SVD or randomized SVD: ΔW ≈ B @ A  (rank r)
4. Register as PEFT LoRA; inference = W + BA

When to use#

  • Multiple policy profiles on one base (factory vs lab adapter)
  • OTA adapter updates without re-downloading 8B weights
  • 8 GB VRAM inference: 4-bit base + rank-16–64 adapter

Rank selection#

RankTypical use
4–8Mild refusal trim, minimal size
16–32Standard abliteration strength
64–128Aggressive decensor; watch MMLU/coding eval

Implementation: ../methods/lora-adapter-export.md


4. QLoRA fine-tune after abliteration (Jarvis / tool repair)#

Different mechanism: SGD on tool-call JSONL teaches compliance behavior; abliteration already removed the refusal direction.

bash
# agentic-security-stack defaults
# QLoRA 4-bit base, rank 32, 1 epoch SFT, 0.5–1 epoch DPO
AspectAbliterationQLoRA Jarvis
DataHarmful/harmless pairsTool-call SFT/DPO rows
ObjectiveRemove direction from weightsMaximize correct tool_call
VRAMOne-shot analysisTraining loop
Needed?Yes (base uncensor)Optional (fixes residual false refusals)

Stack both for factory/CyberGym agents on 12–24 GB cards.

→ ../instructions/agentic-security-stack.md


5. QLoRA “uncensor fine-tune” (alternative, not abliteration)#

Training LoRA on uncensored instruction datasets can reduce refusals without weight projection.

ProsCons
Works on models where abliteration failsNeeds curated dataset; risk of capability collapse
Standard Unsloth/Axolotl toolingNot reversible like keeping base + adapter
Low VRAMMay not fix tool-call false refusals

Use when refusal is distributed (multi-direction). Prefer abliteration + Jarvis for agentic security.

Tools: Unsloth, Axolotl, HF TRL + PEFT.


6. Merged LoRA vs sidecar at inference#

DeploymentCommand / stack
Ollama single GGUFMerge adapter → convert_hf_to_gguf.py (Ollama has no GGUF LoRA sidecar)
vLLM--enable-lora with base + adapter paths
llama.cppconvert_lora_to_gguf.py + --lora / --lora-scaled on llama-cli or llama-server
PEFT dynamicPeftModel.from_pretrained(base, adapter)
GGUF-my-LoRAspaces/ggml-org/gguf-my-lora — browser convert

Export script (this repo):

bash
python scripts/export-abliteration-lora.py \
  --base ./models/ORIGINAL \
  --abliterated ./models/abliterated \
  --out ./adapters/abliteration-r16 \
  --rank 16

GGUF LoRA inference (keep aligned base on disk):

bash
python llama.cpp/convert_lora_to_gguf.py \
  --outfile abliteration-lora-f16.gguf \
  --base-model-id Qwen/Qwen3-4B-Instruct-2507 \
  --lora-path ./adapters/abliteration-r16

./llama-cli -m base-q4_k_m.gguf --lora-scaled abliteration-lora-f16.gguf 0.9

Community abliteration LoRAs: grimjim/Llama-3-Instruct-abliteration-LoRA-8B · ggml-org GGUF LoRA collection

Low RAM inference: Q4_K_M GGUF of merged abliterated weights often beats 4-bit HF + adapter on CPU-only hosts.

→ ../docs/toolchain-safetensors-gguf-lora.md · ../methods/gguf-export-notes.md


Comparison with full abliteration#

CriterionFull weight abliterationLoRA adapter only
Refusal removal strengthStrongTunable via rank & α
KL / capability preservationHeretic optimizes directlyDepends on rank
DiskFull model (~8–16 GB)Base + MB adapter
RevertKeep original safetensorsDisable adapter
Low VRAM surgeryNeeds 4-bit + offloadFactorize after cloud abliteration

VRAMStack
6–8 GBQwen2.5-1.5B + Heretic bnb_4bit → GGUF Q4
8–12 GBQwen3-4B + Heretic bnb_4bit + row_normalization = full
12–16 GBHeretic 4B–8B 4-bit OR llm-abliteration sharded + LoRA export
24 GB+Heretic FP16/BF16; optional Jarvis QLoRA rank 32
Inference onlyCommunity Heretic GGUF + Ollama

References#

Trace this chapter to its source.

The complete Markdown remains the editable source. This page adds navigation, typography, and a visual companion.

techniques/lora-qlora-abliteration.md
Inspect the source fingerprintSHA-256 b4675af1418f39769dcc080f180016d7a1204da773f29808a094be1c16f3077aSource commit 6fba7436a5914cad7c8f0835a14b480a29dac263