Research
Learning from the Undesirable: Robust Adaptation of Language Models without Forgetting
Overview Research area: Machine learning / natural language processing — supervised fine-tuning (SFT) of large language models, regularization, catastrophic forgetting, and robustness of safety alignm
- arXiv
- 2511.13052
- Published
- 2025-11-17
- Authors
- Yunhun Nam, Jaehyung Kim, Jongheon Jeong
AI summary
Overview
- Research area: Machine learning / natural language processing — supervised fine-tuning (SFT) of large language models, regularization, catastrophic forgetting, and robustness of safety alignment.
- Technical level: Intermediate. Readers should be comfortable with language model fine-tuning, cross-entropy training objectives, gradients, LoRA adapters, and internal layer representations.
- One-sentence scope: The paper introduces Learning-from-the-Undesirable (LfU), a regularization scheme that simulates deliberately "undesirable" gradient-ascent updates and then forces the model's internal representations to stay consistent with them, improving generalization and preserving pretrained knowledge during limited-data fine-tuning.
What This Paper Is About
When language models are fine-tuned on small downstream datasets, they tend to overfit: they memorize spurious patterns, lose broadly useful capabilities ("forgetting"), become sensitive to prompt wording, and lose safety behaviors after only a few steps of further fine-tuning. LfU addresses this by treating an intentionally bad update as a form of representation-level data augmentation — the model is trained to keep its internal representations stable even when its parameters are pushed in an undesirable direction.
Key Contributions
- A new consistency-regularization scheme for SFT. LfU builds an auxiliary model by adding trainable components (LoRA matrices per layer, or learnable layer-wise steering vectors) to a frozen base model, applies a single normalized gradient-ascent step to those components to induce "undesirable" behavior, and then penalizes the Mean Squared Error between the original model's internal representations and the perturbed model's representations across all layers, with gradients stopped on the original target (
detach). - Two designs for constructing the auxiliary model. A LoRA-based variant (default in experiments) and a representation-steering (RepS) variant that perturbs hidden representations rather than parameters, positioned as a cheaper alternative.
- A broad empirical study across four models and eleven evaluation tasks in four categories (Math, Knowledge, Reasoning, Helpfulness), in both single-task (GSM8k, ARC-Challenge) and multi-task (Alpagasus Dolly 3k, LIMA) fine-tuning settings, compared against NEFTune, GEM, IM, and SDFT.
- Robustness analyses beyond in-domain accuracy, covering prompt variations, a few steps of adversarial fine-tuning on safety data, input-embedding noise, hyperparameter and layer-selection ablations, and alternative loss designs (feature L1/L2 penalties, logit-level KL consistency, and a SAM-equivalent parameter perturbation).
Main Findings
- In-domain and out-of-domain gains on GSM8k fine-tuning. With Llama-3.1-8B fine-tuned on GSM8k, LfU records the best rank across the four categories and improves over SFT by +5.2% in Math (54.2 vs 51.5) and +3.4% in Helpfulness (45.7 vs 44.1). LfU also achieves the highest rank for Llama-3.1-8B-Instruct, Llama-2-7B, and Mistral-7B-v0.3, where Mistral shows a +4.8% Math improvement over SFT.
- Multi-task fine-tuning on Alpagasus Dolly 3k. LfU attains the highest rank on all four models tested. For Llama-3.1-8B it yields a +16.8% improvement on Math over SFT (43.2 vs 37.0) even though SFT falls below the untuned baseline of 37.9. For Llama-3.1-8B-Instruct it improves Math by +6.5% over SFT, and for Mistral-7B-v0.3 by +20.8% on Math and +7.0% on Helpfulness.
- Reduced sensitivity to prompt wording. Across five ChatGPT-generated prompt variations of GSM8k, LfU shows a 92.1% smaller standard deviation in output performance than SFT while also achieving the highest average accuracy.
- Stronger resistance to adversarial fine-tuning. After safety-aligning Llama-3.1-8B on 5,000 safe BeaverTails refusal pairs for 3 epochs and then running only 5 steps of adversarial SFT on harmful BeaverTails, LfU shows markedly lower attack success rates: 5.8 vs 34.8 (SFT) on HEx-PHI, 10.0 vs 55.0 on PureBad, and 0.6 vs 7.3 on AdvBench. The paper reports that LfU reduces ASR by 18.4% on HEx-PHI and 27.0% on PureBad relative to the second most robust method, and states up to a 45.0% lower ASR on harmful datasets over SFT.
- Greater internal stability under input noise. Measuring cosine similarity between internal representations of clean and Gaussian-noised inputs on GSM8k-fine-tuned Llama-3.1-8B, LfU shows the highest similarity across layers, exceeding NEFTune even at the same noise level.
- Representation-level consistency beats parameter-level and logit-level alternatives. In the loss-design comparison, LfU's representation MSE (Math 54.2) outperforms vanilla SFT (51.5), a SAM-style direct parameter perturbation (53.3), feature L1 (53.1), feature L2 (53.6), and logit-level KL consistency (53.9).
- RepS is faster but slightly weaker in-domain. Per-step time on a single NVIDIA H100 (80GB): SFT 1386.9 ± 6.4 ms, LfU (LoRA) 4142.4 ± 14.2 ms, LfU (RepS) 2332.1 ± 9.1 ms. LfU (RepS) is nearly twice as fast as LfU (LoRA) and reaches competitive overall scores (Math 53.2, Helpfulness 48.5) with a slight drop in in-domain performance.
- Hyperparameter and layer choices matter. In the ablation on Llama-3.1-8B/GSM8k, larger λ improves in-domain (Math) performance while slightly reducing out-of-domain performance, with λ = 5.0 chosen as the balance; an excessive step size (α = 0.5) severely distorts the model and collapses performance (Math 44.5). Applying the consistency loss to all layers beats Early (layers 1–11), Middle (12–22), or Late (23–32) subsets individually, though all subsets still provide gains.
Methodology in Plain English
LfU keeps the normal SFT loss on the main model. In parallel, it creates a temporary "auxiliary" copy of the model by attaching small trainable pieces — either low-rank LoRA matrices added to each layer, or a learnable vector added to each layer's hidden state. It then takes one step in the wrong direction, using the normalized gradient of the SFT loss with respect to those added pieces, so the auxiliary model becomes deliberately worse. Finally, it compares the hidden representations of every layer of the clean model with those of the corrupted model and adds a penalty (mean squared error) whenever they drift apart. The clean model's representations act as a fixed target, so this penalty pushes the training toward solutions whose internal states barely move when the model is nudged toward bad behavior. Because the perturbation is applied to internal representations, it functions like data augmentation at the feature level rather than at the input level.
Why This Matters
- Research impact: The work reframes a gradient-ascent step — usually a technique for finding flatter minima (e.g., SAM) or a way to attack a model — as a generator of representation-level augmentations, and shows the representation-level consistency objective outperforms both parameter-level perturbation and logit-level consistency. It also connects the overfitting problem in SFT to safety-alignment fragility.
- Real-world applications:
- Fine-tuning assistants on small curated datasets (in the spirit of the 1,000-example LIMA benchmark) without degrading unrelated capabilities.
- Domain adaptation in regulated or low-data settings such as medical, legal, or scientific question answering, where preserving general knowledge is essential.
- Safety-critical deployments where refusal behavior must survive further downstream fine-tuning by third parties.
- Prompt-robust production systems that must behave consistently across different phrasings of the same request.
- Industry relevance: SFT is the standard adaptation step in nearly every deployed language model pipeline, and LfU is compatible with LoRA-style parameter-efficient fine-tuning. The trade-off is compute: LfU (LoRA) costs roughly three times the per-step time of plain SFT (4142.4 vs 1386.9 ms on a single NVIDIA H100 80GB), while the RepS variant roughly halves that overhead.
Future Directions
- Extending the "undesirable update" idea beyond supervised fine-tuning to preference optimization or reinforcement-learning-based alignment, which the paper does not test.
- Choosing λ and α automatically, since the ablation shows a trade-off between in-domain alignment (Math) and out-of-domain generalization that currently requires manual tuning, and because the values used differ substantially across models (λ = 5 for Llama-3.1-8B LoRA versus λ = 500 for Llama-3.1-8B-Instruct).
- Scaling the evaluation to larger models, more layer-selection strategies, and additional modalities; the layer study here covers only Llama-3.1-8B grouped into Early (1–11), Middle (12–22), and Late (23–32).
- Investigating how far the adversarial robustness advantage extends — the safety experiment uses only 5 adversarial steps, 3 epochs on 5,000 BeaverTails pairs, and three evaluation sets (HEx-PHI, PureBad, AdvBench).
- Combining LfU with data-level augmentation and synthetic data, which the paper discusses as an alternative but does not combine with its own method.
Target Audience
Researchers and practitioners working on language model fine-tuning, parameter-efficient adaptation, and model reliability — particularly those who need to specialize a model on limited data without losing general capabilities or safety behavior. It is also relevant to engineers evaluating the compute-versus-robustness trade-off of regularization methods, since the paper reports per-step timing for both LfU variants. Readers without background in SFT objectives, LoRA, or hidden-state representations will need to consult the cited background material first.
Authors’ abstract
Language models (LMs) are often adapted through supervised fine-tuning (SFT) to specialize their capabilities for downstream tasks. However, in typical scenarios where the fine-tuning data is limited, e.g., compared to pre-training, SFT can lead LMs to overfit, causing them to rely on spurious patterns within the target task or to compromise other broadly useful capabilities as a side effect of narrow specialization. In this paper, we propose Learning-from-the-Undesirable (LfU), a simple yet effective regularization scheme for SFT to mitigate overfitting issues when fine-tuning LMs with limited data. Specifically, we aim to regularize the fine-tuning process to favor solutions that are resilient to "undesirable" model updates, e.g., gradient ascent steps that steer the model toward undesirable behaviors. To this end, we propose a novel form of consistency regularization that directly aligns internal representations of the model with those after an undesirable update. By leveraging representation-level data augmentation through undesirable updates, LfU effectively promotes generalization under limited data. Our experiments on diverse LM downstream tasks show that LfU serves as an effective prior that enhances adaptability while preserving pretrained knowledge. For example, our LM from LfU achieves a 16.8% average improvement on math tasks compared to vanilla SFT on the same dataset, where the latter even leads to degraded performance on those tasks. Furthermore, LfU exhibits improved robustness to prompt variations, e.g., yielding a 92.1% lower standard deviation in output performances compared to SFT, highlighting its versatile effects.