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

Preventing Catastrophic Forgetting: Behavior-Aware Sampling for Safer Language Model Fine-Tuning

Anh Pham, Mihir Thalanki, Michael Sun, Aditya Chaloo, Ankita Gupta, Tian Xia, Aditya Mate, Ehimwenma Nosakhare, Soundararajan SrinivasanarXiv 2025 · DOI

Abstract

Fine-tuning large language models (LLMs) on benign datasets often leads to "catastrophic forgetting" of safety alignment. This paper proposes a behavior-aware sampling framework that maintains safety by injecting a minimal set of strategically selected "refusal" (T1) examples across diverse harm categories. Results demonstrate that as little as 0.05% additional training data can reduce harmfulness by up to 41%, significantly outperforming random sampling baselines while avoiding the pitfalls of over-rejection.

Introduction

Supervised Fine-Tuning (SFT) is a standard practice for adapting pre-trained LLMs to specific domains like coding or creative writing. However, this process frequently erodes the model's previous safety alignment. Because fine-tuning datasets typically consist of "benign" instructions, models essentially "unlearn" how to refuse harmful prompts.

While mixing random safety data into the SFT process can mitigate this, it is often inefficient. Large safety datasets are expensive to curate and can lead to over-rejection, where models become excessively cautious and refuse harmless queries. This research investigates the principles of data efficiency in safety alignment, identifying which specific examples are most effective for maintaining safety without compromising utility.

Methodology: Behavior-Aware Sampling

The proposed framework selects safety examples based on two primary dimensions: instruction-response behavior and categorical diversity.

1. Instruction-Response Behavior

The authors categorize safety data into four distinct types:

  • T1 (Refusal of Harmful Instruction): The model correctly identifies a harmful prompt and refuses it.
  • T2 (Compliance with Harmful Instruction): The model generates unsafe content.
  • T3 (Unnecessary Refusal of Safe Instruction): The model over-rejects a benign prompt.
  • T4 (Compliance with Safe Instruction): The model correctly follows a benign prompt.

2. Sampling Strategies

To ensure broad coverage, the authors introduce two main sampling strategies:

  • Stratified Safety Sampling (SSS): Uniformly sampling across harm categories (e.g., hate speech, illegal acts) to ensure balanced representation.
  • Prototypical Safety Sampling (PSS): Utilizing embeddings to identify the most representative examples for each category.

By combining these strategies, the authors developed SSS-B and PSS-B, which prioritize T1 (refusal) behaviors while maintaining categorical diversity.

The behavior-aware sampling workflow, illustrating the selection of T1 samples across diverse harm categories for injection into the training data.

Experimental Setup

The framework was evaluated using a base fine-tuning dataset of 20,000 instruction-response pairs from a cleaned version of Alpaca. Safety samples were drawn from the Safety-Tuned Llama dataset. Evaluation benchmarks included BeaverTails-Evaluation, SALAD-Bench (for attack success rates), and XSTest (for over-rejection rates). The methods were validated across multiple architectures, including LLaMA 2, LLaMA 3, Qwen 2.5, and Mistral 7B.

Results and Discussion

The experimental results highlight several key insights regarding safety data efficiency:

  • Quality Over Quantity: A very small number of high-quality samples (50–150) proved more effective than thousands of random samples. Using SSS-B with just 150 samples (0.05% of the total training data) reduced harmfulness by 41% compared to the baseline.
  • The Power of Refusal: T1 behavior is the most potent signal for safety. Explicitly teaching the model to say "I cannot assist with that" helps it recognize harmful intent across various contexts.
  • Generalization and Diversity: Broad coverage across harm categories is essential for generalization to unseen harmful prompts.
Comparison of Harm Reward Model Scores across different sampling sizes, showing that behavior-aware methods (SSS-B, PSS-B) significantly outperform random sampling.

As shown in the results, behavior-aware sampling methods consistently achieve lower harm scores with fewer samples compared to random sampling. On the SALAD-Bench, SSS-B reduced the Attack Success Rate (ASR) to 20.39% at 150 samples, whereas random sampling remained at 27.39% and the baseline exceeded 50%.

Conclusion

This work demonstrates that catastrophic forgetting of safety alignment can be prevented with minimal data overhead. By focusing on diverse refusal behaviors (T1), developers can maintain model safety without triggering excessive over-rejection. Future research will explore dynamic sampling during the training process and investigate the gradient-level mechanisms that allow such small amounts of data to protect the entire model representation.

Summary updated

BibTeX
@misc{pham2025preventing,
  author = {Anh Pham and Mihir Thalanki and Michael Sun and Aditya Chaloo and Ankita Gupta and Tian Xia and Aditya Mate and Ehimwenma Nosakhare and Soundararajan Srinivasan},
  title = {{Preventing Catastrophic Forgetting: Behavior-Aware Sampling for Safer Language Model Fine-Tuning}},
  year = {2025},
  eprint = {2510.21885},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.21885},
}
Figure