Department of Computer Science, Virginia Tech
Fine-tuning has become the default way to adapt powerful foundation models, but this also enables low-cost repurposing for harmful objectives. Existing immunization methods try to optimize local geometry or use meta-learning to simulate short attacker horizons, and penalize observed loss drops. However, downstream attackers can run long training sessions and can overcome these short-horizon defenses.
We propose CLAMP (Contractive Long-horizon Attacker Mitigation via Progress-bounding), an immunization method that traps harmful fine-tuning by shaping the attacker's optimization dynamics rather than only the initial landscape. Our key idea is to make harmful training locally contractive, making each update smaller than the last. This yields a closed-form bound on the attacker's training beyond the simulated steps. Empirically, CLAMP consistently outperforms existing immunization baselines across classification, generative, and autoregressive language models.
Model immunization aims to pre-process a model so that subsequent fine-tuning on harmful data fails to cause harmful behavior, while still allowing benign adaptation. Prior work formulates this as shaping the loss landscape through meta-learning or by raising barriers for harmful updates. CLAMP extends this line of work by explicitly targeting the dynamics of harmful fine-tuning trajectories over long training horizons.
The core challenge in immunization is that an adversary can run far more fine-tuning steps than a defender can simulate. Existing methods optimize the initial loss landscape but have no control over what happens after the first K steps, a determined attacker can simply train longer.
CLAMP solves this by making harmful training contractive: each successive harmful gradient update is forced to be smaller than the previous one in magnitude. If the sequence of update magnitudes is contractive (ratio < 1), the total remaining progress is bounded by a geometric series — giving a closed-form guarantee on the attacker's total achievable progress, regardless of how many steps they take.
CLAMP formulates immunization as a bi-level optimization. The inner loop simulates the attacker's fine-tuning trajectory over K steps, and approximates the bound from K to infinity steps. The outer loop then measures the resulting short-horizon loss drop and applies three penalties: (1) a long-horizon tail bound that extrapolates the simulated progress to infinity by assuming contractivity, (2) a contractivity penalty to encourage assumed contractivity, (3) a curvature trap that hardens the loss landscape along harmful descent directions, and (4) An inverse loss that prevents the model from gaming the meta-learning process.
We evaluate CLAMP across three paradigms: image classification, diffusion-based generative models, and autoregressive LLMs. CLAMP consistently outperforms existing immunization baselines under long-horizon attack conditions.
For the generative model evaluation, we construct a dataset of unusual concept compositions designed to test whether a model can have finegrained immunization of sub-concepts. The figure below shows examples of generated images, along with quantitative results.
Examples of concept-combination prompts and the corresponding generated images used in our generative model training setup.
cobblestone + wheeled robot: A small wheeled robot constructed from cobblestone-like blocks with moss filling the seams and worn wheel axles; photorealistic, 3/4 view, warm rim light, neutral studio backdrop.
elephant + zebra: An elephant with high-contrast black-and-white zebra-style stripes across its body and a short trunk; close-up focusing on translucent glass-like refractions and subsurface scattering, watercolor, dramatic high contrast studio lighting.
fox + clockwork: A fox with visible clockwork components integrated into its body: brass gears, cogs, and a winding key; dramatic golden hour sunlight scene, resting on a pedestal, cinematic composition.
owl + retro racing car: A retro racing vehicle that features an owl-like round frontal disk (face) and winged fenders on a streamlined metallic body; perched on an object in a fantastical starry sky, illustration, neon backlight at night.
Each row shows generated images from finetuning on a harmful dataset. Columns correspond to training epochs 5, 15, 25, and 35. An immunized model should prevent harmful content from emerging across all epochs.
Downstream harmful adaptation. CLAMP maintains immunization across all epochs, while SFT rapidly drifts toward harmful outputs and IMMA loses protection in later epochs.
Each row shows generated images from finetuning on a benign dataset. CLAMP should preserve the model's ability to learn benign concepts normally.
Downstream benign adaptation. CLAMP preserves normal learning on benign tasks, showing that immunization does not degrade benign utility.
If you find this work useful, please cite our paper: