NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Shifting the Gradient: Understanding How Defensive Training Methods Protect Language Model Integrity

Satchel Grant, Victor Gillioz, Jake Ward, Thomas McGrathNeurIPS 2026

TL;DR

Paradoxically, if you want to stop a language model from learning a harmful trait (like being "evil") from poisoned training data, you can actively force the model to express that exact trait during training, then remove the trigger at inference. Two popular methods—Positive Preventative Steering (PPS) and Inoculation Prompting (IP)—use this trick, raising the question: are they doing the same thing under the hood? It turns out they aren't interchangeable: while IP gently "explains away" bad behavior in the loss, PPS actively reverses the training gradient to push back against the trait, allowing it to even cure models that have already gone bad.

What Problem Does This Paper Address?

When fine-tuning Large Language Models (LLMs), training data can contain undesirable behaviors—sycophancy, hallucinations, or outright malice. Enter defensive training methods. Both Positive Preventative Steering (PPS) and Inoculation Prompting (IP) inject a "defensive object" into the model during fine-tuning on bad data: PPS adds an internal activation vector representing the bad trait, while IP prepends a prompt instructing the model to act out that trait. At test time, you remove the vector or prompt, and remarkably, the model hasn't learned the bad behavior.

Despite their practical success, these methods have been treated largely as black boxes. Do they just teach the model to associate bad behavior with a temporary trigger? Can they undo existing misalignment? Knowing how they work is the difference between guessing at hyperparameters and engineering reliable AI safety.

Methods

The authors compare standard LoRA fine-tuning under PPS and IP primarily on Qwen2.5-7B-Instruct (and replicated across Qwen2.5-14B, Llama-3.1-8B, and Qwen3-4B):

  • PPS adds a "persona vector" (PV)—computed as the mean activation difference between on-trait and anti-trait responses—to a single intermediate layer during the forward pass.
  • IP prepends a trait-eliciting prompt sampled from a small prompt-bank (rather than the standard single fixed prompt, which lets the authors tune IP's strength).
  • Fair Calibration (Novel): To compare apples to apples, the authors calibrate the strength of PPS (steering intensity $\epsilon$) and IP (prompt-bank size $n$) by matching their "collateral damage" on a benign co-occurring trait—specifically, whether the model can still learn to write in ALL-CAPS while defending against "evil" content in the same text.
  • Mechanistic Probes & Interventions (Novel): They measure the cosine similarity between the negative loss gradient ($-\partial\mathcal{L}/\partial h$) and the trait's persona vector to see if training amplifies or attenuates the trait. They also directly hijack backward-pass gradients to test causality.
Figure 1: PPS and IP shift the training signal along the trait axis. (a) Schematic of the gradient shift: the activation’s component along the “evil” persona vector (PV) v, ⟨h, v⟩, and the training signal on it, ⟨−∂L/∂h, v⟩. Without defense, training on “evil” data pushes the activation further along the PV; adding the PPS vector ϵv to the forward pass reverses the push. (b) The measured shift in six traits on Qwen2.5-7B-Instruct and for “evil” on three other models: ¯C, the cosine between −∂L/∂h and each setting’s own PV at its steering layer, with no defense (grey squares), PPS (purple circles) and IP (green diamonds), at the nearest available calibration match where applicable; pirate, all-caps and optimism use fallback defaults (Appx. H.1). PPS shifts the gradient to attenuating (shaded) in every setting, and further than IP. (c) Trait expression after finetuning in the same settings. Both defenses reduce expression, but the size of the gradient shift along the PV axis does not order their defensive strength (Section 4.3).

Datasets

The authors do not introduce a standalone benchmark, instead adapting chat datasets from the existing persona vectors repository (Chen et al., 2025). They generate training data across six traits: evil (split into Medium and Heavy intensities), sycophancy, hallucination, optimism, pirate speech, and all-caps (including an ALL-CAPS "evil" variant for calibration). Post-training trait expression and coherence are scored (0–100) by GPT-4.1-mini on 20 open-ended trait-eliciting questions, validated against Llama-3.3-70B-as-a-judge.

Key Insights and Ideas

  • It’s not just simple Pavlovian conditioning: A natural guess is that the model merely links the bad trait to the defensive cue. If true, any random vector or neutral prompt would work. They don't—retaining 95%–98% of the bad trait. The defense must actively match the trait.
  • PPS is an antidote; IP is mostly a vaccine: If a model already expresses a harmful trait before fine-tuning, IP barely makes a dent in removing it. PPS, however, actively scrubs pre-existing traits out of the model.
  • Flipping the gradient: Normally, training on "evil" data creates an amplifying gradient along the evil persona axis. PPS supplies more evil activation than the data calls for, causing the model to overshoot and reversing the gradient into an attenuating pushback. IP shifts the gradient much more diffusely, bringing it only near zero along that axis.
  • Two views of one signal: Intuitive wisdom says defenses "explain away" bad data, lowering prediction loss. IP indeed lowers loss, whereas PPS actually raises loss at effective steering intensities. Using the chain rule, the authors show these aren't competing mechanisms: the loss hits a local minimum right where the gradient flips from amplifying to attenuating. Loss measures error size; gradient cosine measures error direction.

Key Results

  • Preventing vs. curing "evil" (0–100 scale): On Heavy evil data, undefended training scores 91.7. Calibrated PPS ($\epsilon=2$) and IP ($n=3$ prompt bank) bring this down to 33.3 and 31.6, respectively. However, when starting from an already-evil model (91.7), continuing training with PPS slashes evilness by 61.0 points, whereas IP reduces it by just 0.7 (even single-prompt IP only manages modest reductions of ~5–10 points in shallower regimes).
Behavioral comparison showing both methods prevent trait acquisition from a clean base model, while PPS also substantially reduces pre-existing trait expression.
  • Causal gradient surgery: Forcing the backward gradient along the evil axis to be attenuating during 1 epoch of undefended evil training drops evil expression from 90.0 to 0.5. Conversely, forcing an amplifying gradient on completely normal data turns the model evil (97.7).
  • Pre-training diagnostics: Measuring base-model gradient cosines predicts cross-trait defenses before training even starts. An "evil" PPS vector flips the sycophancy gradient negative and successfully defends against sycophancy (94.1 $\rightarrow$ 59.2), whereas a sycophancy vector fails to flip the evil gradient and fails to block evilness (91.7 $\rightarrow$ 81.4).

Limitations and Future Work

  • Not the whole story: The persona-axis gradient shift is only part of how these defenses work. Deleting that specific gradient component weakens PPS (expression rises from 23.6 to 43.2) rather than breaking it completely, and leaves IP completely unfazed (1.2 to 1.1). Furthermore, a strong gradient shift doesn't guarantee success (e.g., PPS strongly shifts the hallucination gradient on Qwen2.5-7B but barely defends: 99.3 $\rightarrow$ 86.0).
  • Fragility and scope: Directly forcing gradient signs degrades model coherence after one epoch, and in-depth mechanistic analyses focused on LoRA fine-tuning of a single 7B model.
  • Future directions: Mapping how defensive objects alter errors in directions beyond the single persona axis, and examining token-by-token loss changes specifically on trait-heavy tokens, remain open puzzles toward a complete mechanistic theory.

Summary updated

BibTeX
@inproceedings{grant2026shifting,
  author = {Satchel Grant and Victor Gillioz and Jake Ward and Thomas McGrath},
  title = {{Shifting the Gradient: Understanding How Defensive Training Methods Protect Language Model Integrity}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=F3oGUNdzUB},
}
Figure