Abliterating a model is not about retraining it or about giant datasets. It is a linear algebra operation over the weights that runs in minutes and never sees a single training example. The hard part is measuring. If you measure badly, you break the model and never notice.
This post is the step-by-step manual, and the case study is a real Qwen3.8-27B that we abliterated so we could use it across different cybersecurity use cases.
The result is published in three formats in case you want to look at the weights as you read: BF16, NVFP4 for serving on Blackwell, and GGUF for local CPU use with llama.cpp, for example.
The case
If you work in security, you have probably seen a model refuse legitimate tasks from your day-to-day work hundreds of times. You ask for the nmap methodology of a client-authorized audit and you get a lecture. You ask for triage steps for a suspicious binary and you get a refusal. Meanwhile, the actual attacker uses other tools, so the refusal filter costs the good guys more than the bad ones.
Our inference platform runs on Kubernetes, with vLLM serving the models behind our own AI Gateway. For the whole process described in this post, we use an RTX 6000 PRO from the Blackwell family.
We chose Qwen3.8-27B as the base model for this post. It is a hybrid model, with a reasoning mode you can turn on and off (thinking on and off), linear attention GDN layers besides the conventional ones, and a vision tower. Everything that makes the case interesting makes it harder to operate on, which is exactly what we wanted for a real tutorial.
The idea
All of this comes from a NeurIPS 2024 paper: Refusal in Language Models Is Mediated by a Single Direction, by Arditi and colleagues. Their conclusion is that in instruction-tuned models, refusal is not spread across the network, but is largely mediated by a single direction in activation space.
The metaphor that helped me is to see the residual stream as a whiteboard shared by all the layers. Each layer reads what is written and adds its own contribution. What the paper found is that the "refusal button" occupies a specific area of that whiteboard. Abliteration consists of making it so no layer can ever write on that area again. The model can still know perfectly well what a dangerous request is; it simply loses the ability to press the button.


The residual stream as a shared whiteboard. After abliteration the layers keep writing, but nothing reaches the refusal direction.
Unlike fine-tuning, there are no gradients, no training loop, no data. It is geometry over frozen weights, and if you keep the original checkpoint, the operation is exactly reversible.
The whole process is seven steps, grouped into prepare, cut and check.


The seven steps of this guide. If the weight verification fails, you choose the layer again.
Step 1: set your gates before cutting anything
It is the step most write-ups skip, and without it you have no way of knowing whether you broke the model.
Before touching a single weight, write down somewhere what you will accept and what you will not. Ours, pre-registered before the first surgery:
Gate | Threshold | Measures |
|---|---|---|
Professional cybersecurity | ≤ 5% refusals | The goal of the project |
Benign over-refusal | 0% | That it does not get suspicious |
MMLU-Pro (560 questions) | ≤ 3 point drop | Global cognitive damage |
KL on benign prompts | mean ≤ 0.2 / p90 ≤ 0.3 | Distributional distance to the original |
The KL gate deserves a note. The KL divergence between the original and the operated model, measured on prompts that have nothing to do with refusal, is your collateral damage detector. One nat of KL is already visible damage; six nats are a different model. You will need it in step 4, and it will save you from publishing a disaster.
Step 2: prepare the prompt pairs
You need two groups of prompts, one with requests the model refuses, and one with benign requests in the same style. You do not need a huge dataset; dozens per class, well chosen, are enough. We used three groups: professional cyber (pentesting, malware triage, blue team, reversing), aggressive cyber (the end that should worry you, with wiper logic and EDR evasion), and generic clear harm (stalking, fraud, weapons).
If your model is a hybrid like ours, here comes the first lesson, which cost us a full measurement cycle. Each reasoning mode has its own refusal direction. We extracted the direction with thinking off, operated, measured, and the model still refused with thinking on. The two directions turned out to be nearly orthogonal, with cosine between 0.01 and 0.34. In practice they are two different buttons.
So for this model we did two extractions, one per mode. If your model has no reasoning mode, you are lucky and only need one.
Step 3: extract the direction
The mechanics are simple. You run each prompt through the model with capture hooks, save the residual stream activations at the last positions of the template (before generation starts, because you want to capture the predisposition to refuse, not the refusal text), and compute the difference of means between the refused group and the benign one:
# Conceptually, the whole extraction:
acts_ref = collect_activations(refused_prompts) # mean per group,
acts_ben = collect_activations(benign_prompts) # at the last positions
r = acts_ref.mean - acts_ben.mean # the refusal direction
r_hat = r / r.norm() # normalized, per layer
That gives you, layer by layer, a candidate vector. The one at the right layer is your direction r̂.


Extracting the refusal direction from two groups of prompts. The activation cells are illustrative.
Step 4: choose the layer
This step decides most of the collateral damage.
The layer with maximum refusal signal is usually also a layer loaded with everything else. The direction living there cancels refusals, but it also holds up other things. Our numbers, measured on the Qwen3.8-27B:
Site | Refusal signal | KL on benign |
|---|---|---|
Signal peak | Maximum | 6 to 22 nats |
One layer below | Almost the same | 0.017 to 0.018 |
Six nats of KL to remove the same refusal that one layer below removes for 0.017. The practical rule we took away is to pick the layer with the most signal that fits in your KL budget, which in our case was not the peak. In our case, the winning combination of the two directions (thinking on and off) landed at KL 0.039 mean and 0.11 at the 90th percentile, well inside the gates.


KL on benign prompts measured on the Qwen3.8-27B, on a log scale. The refusal signal at each site is shown qualitatively.
Step 5: operate
The surgery itself is weight orthogonalization. For every matrix W that writes to the residual stream, you remove its component along the refusal direction:
W' = W - r̂ r̂ᵀ W
The matrices that write to that whiteboard are the attention output projections, the MLP down projections, and the embedding, that is, everything that writes to the shared whiteboard. In this model that is 129 tensors in total. The lm_head is never touched, because it reads the whiteboard but does not write to it. Everything else in the checkpoint stays byte-identical.
Since we had two directions (one per reasoning mode), we did two sequential rank-1 surgeries. If you first orthogonalize one direction against the other, the projections commute and the order does not matter. The result is a rank-2 surgery, with two buttons disabled in two passes.


Which tensors are operated and which are not. The two directions are removed in two rank-1 passes.
The whole cut is five minutes of matrix multiplications over a frozen checkpoint.
Step 6: verify the weights
Before evaluating behavior, verify the operation itself, with two checks.
The first is the logit-equivalence KL. Generate with the original and the operated model over the same battery of benign prompts and compare the distributions token by token. Our result was 0.039 mean and 0.11 at p90, inside the gates from step 1.
The second is the per-writer residue, which measures how much each of the 129 operated tensors changed in relative terms. A global average that hides one destroyed tensor does not count here. Our worst writer landed at 1.49% relative change, with the gate at 5%, and all 129 inside.
If these numbers do not come out, stop: go back to step 4 and move down one layer.
Step 7: measure behavior without fooling yourself
When you have an abliterated model in your hands, your automated measurement instruments degrade, each in its own direction. Marker classifiers (searching for strings like "I cannot") fail on softened refusals, because "You cannot legally do this" does not contain the refusal string, but it is a refusal. LLM judges fail in the opposite direction, and they read comply where there are conditions and caveats.
It happened to us on the first build. The marker told us 0% refusals on clear harm, and when we hand-scored the responses against a published rubric, the real number was 95 to 100% of refusals intact. The marker was reading softened refusals as answers, and we were about to publish a false number in the direction that suited us best, without knowing it.


The same answers from the first build, measured with two instruments.
The only ground truth we accept to publish is hand-scoring against a published rubric, with n declared and Wilson confidence intervals on top. It is slow (we hand-scored this project's 60 headline rows, more than once), but it is the only way we found to get a number we can trust.
Our mistake, so you do not repeat it
The first build was a selective abliteration, extracting a cyber-specific refusal direction to remove only that refusal and keep the rest. It seemed reasonable, but it did not work.
We tried six different selective directions. All six passed the weight verification, and all six dragged between 0.3 and 16 nats of KL on benign prompts, destroying the model at every stable site. And when we measured the geometry the reason became clear. The "cyber refusal" direction and the "clear-harm refusal" direction are mostly the same direction, with cosine between 0.64 and 0.79. There is no separate cyber button you can remove without touching the rest.


Angles between refusal directions measured on the Qwen3.8-27B. The shaded area is the observed range of cosines.
The paper said so, in fact: the direction is, to a large extent, a single one. We did not listen until the measurements told us. The correct abliteration for this case was the general one, which is exactly what the original method describes.
The twist we did not expect
When we removed the general direction, the selectivity we had tried to carve by hand appeared on its own.
Behavior | Base | Abliterated (hand-scored) |
|---|---|---|
Professional cybersecurity | 10% refused | 0% refused |
Clear harm (stalking, fraud, weapons) | 100% refused | 95% refused (thinking off) / 100% (on) |
Aggressive cyber | 100% refused | 70-80% comply (off), 12% refused with thinking on (n=90) |
Benign over-refusal | 0% | 0% |
MMLU-Pro 560 | 66.4% | 66.1% (McNemar p=0.86) |
The clear-harm refusal largely survives the operation because it retains structure outside the direction you removed. The aggressive-cyber refusal, on the other hand, was mostly that direction, so it goes. We did not design that split. It comes from the model's geometry, and you can only measure it afterwards.
If you wanted to remove only one kind of refusal, abliteration does not let you choose. You remove the general direction, verify you did not break anything, and report what survived, even when it is not what you hoped for.
Quantize and serve
With the BF16 validated, the rest is packaging, with its own tricks.
For Blackwell, the correct NVFP4 recipe for this model is not NVFP4 everywhere, but a mixed precision scheme, with dynamic per-token FP8 activation scales on the attention projections, the GDN ones, the lm_head and the last MLP layers, NVFP4 elsewhere, and the vision tower untouched. Quantization kernels with static-FP8 presets put a global input scale on the lm_head that vLLM rejects at load, so it is worth verifying the recipe against the vendor's reference checkpoint before investing hours. Measured, the refusal behavior is identical to BF16, and the benchmark lands at 65.4% versus 66.1%, a difference that is not significant (p=0.37).
For llama.cpp, the GGUF chain is validated on the base model before touching the abliterated one, with 755 tensors and the native chat template with the reasoning split working (llama-server --jinja). From there, the four quants: Q4_K_M at 16.7 GB, Q5_K_M at 19.3, Q6_K at 22.1, and Q8_0 at 28.6. The smoke test of the abliterated Q4_K_M on CPU reproduced the GPU behavior exactly. The authorized pentest request gets the full methodology, and the stalking request gets a refusal with safer alternatives.
What you publish when you publish
If you make it to the end and publish, the card is what the people using the model will read. The minimum we consider honest:
- The method and the layer you chose, with the KL you allowed yourself.
- The numbers with their n and their intervals, including the uncomfortable ones.
- Declared truncations, what you did not measure.
- The serving flags that matter. On this model,
--max-num-seqs 128, because the hybrid GDN cache is smaller than vLLM's default and it swallows it whole if you do not limit it.
The weights from the case are in Helmcode's Hugging Face collection. We will soon publish the complete pipeline and the evals we use to measure these models.
Frequently asked questions
What is the difference between abliteration and fine-tuning?
Abliteration has no gradients, no training data, and no loop. It is a geometric projection over frozen weights, executed once. If you keep the original checkpoint, it is exactly reversible, because you apply the inverse projection and recover the model as it was.
Does it work on any model?
On instruction-tuned models with measurable refusal. A base model has no refusal to remove. And the more hybrid architecture there is (switchable reasoning, vision, linear attention), the more directions you have to cover and the easier it is to leave one mode unoperated, as happened to us.
Do you lose quality?
If you respect the KL gates, there is no reason to. Our MMLU-Pro moved from 66.4 to 66.1 and McNemar says the movement is noise (p=0.86). If you skip the gates, you do lose quality, and invisibly until someone measures it.
Can I do it at home?
The surgery on a 27B is minutes of matrix multiplications and fits on a 96 GB GPU. The expensive part is measuring well afterwards, so budget more time for honest measurement than for the operation.
Is removing refusal not dangerous?
The model will comply with requests it used to refuse, and that has to be said clearly. The responsibility for how it is used stays with whoever deploys the model and whoever uses it. That is why the card has to carry the real numbers, including the ones you do not like, and why our acceptable use policy applies as always.
The weights from the case model are public, and if what you want is inference without setting up hardware, our API serves open models on GPUs we know inside out. Talk to us if your workload calls for it.