@article{asft2025,title={AsFT: Anchoring Safety During LLM Fine-Tuning Within Narrow Safety Basin},author={Yang, et al.},year={2025},note={NeurIPS 2025, arXiv:2506.08473},}
The safety subspace here is a low-rank set of weight-space directions
derived from the aligned model (via compute_safety_subspace, either from
the aligned − base delta or from safety-prompt activations) — not the
same thing as the safety neurons/circuits Interpret locates; it's specific
to this projection-based defense. SaLoRATrainer below wraps these same
two functions into a Trainer-style API — see its "When to use" for which
form to reach for.
fromsafetune.hardenimportcompute_safety_subspace,project_lora_step# Derive the per-parameter safety subspace from the aligned model# (returns a dict of projection bases keyed by parameter name).safety_subspace=compute_safety_subspace(aligned,# nn.Module — aligned reference modelbase=None,# optional nn.Module — pre-alignment baserank=8,safety_inputs=None,# optional iterable of tokenized safety batches)# Install the safety projection onto `model`; returns the number of# modules projected.n_projected=project_lora_step(model,safety_subspace)
Best for: alignment-stage defense that appends a finite-difference harmful-gradient regularizer to the SFT objective — attenuating directions along which a harmful attacker would quickly reduce the harmful loss.
Trade-offs: requires two backward passes through the harmful set per outer step (clean + perturbed). Larger perturb_scale increases robustness but can hurt task accuracy.
@article{booster2025,title={Booster: Tackling Harmful Fine-Tuning for Large Language Models via Attenuating Harmful Perturbation},author={Huang, et al.},year={2025},note={ICLR 2025 Oral, arXiv:2409.01586},}
Best for: LoRA fine-tunes where you want the task adapter update to stay orthogonal to the safety-critical representation subspace (extracted via incremental GPU SVD on safety calibration data).
Trade-offs:safety_rank controls the dimensionality of the protected subspace — higher values preserve more safety at the cost of available task capacity in the adapter.
vs. SaLoRA above: same projection method; this is the Trainer-style wrapper (auto-loads safety_dataset, drives the full train() loop). Use the plain functions above if you're managing the training loop yourself.