Fundamental Safety-Capability Trade-offs in Fine-tuning Large Language Models

Pin-Yu Chen, Han Shen, Payel Das, Tianyi ChenarXiv 2025

Abstract

Fine-tuning Large Language Models (LLMs) on some task-specific datasets has been a primary use of LLMs. However, it has been empirically observed that this approach to enhancing capability inevitably compromises safety, a phenomenon also known as the safety-capability trade-off in LLM fine-tuning. This paper presents a theoretical framework for understanding the interplay between safety and capability in two primary safety-aware LLM fine-tuning strategies, providing new insights into the effects of data similarity, context overlap, and alignment loss landscape. Our theoretical results characterize the fundamental limits of the safety-capability trade-off in LLM fine-tuning, which are also validated by numerical experiments.

Introduction

The rapid adoption of Large Language Models (LLMs) has led to a standard workflow: pre-training, alignment (e.g., RLHF) to ensure safety, and subsequent fine-tuning on domain-specific datasets to enhance "capability" (such as coding or reasoning). However, a persistent challenge is that fine-tuning often inadvertently breaks the model's safety guardrails, even when the fine-tuning data is benign. This paper provides a rigorous mathematical foundation for this "safety-capability trade-off," moving beyond empirical observations to identify the theoretical drivers of safety degradation.

Theoretical Framework

The authors formalize the trade-off using optimization theory, focusing on two primary safety-preserving strategies:

  1. Case I: Alignment Loss Constraint: Fine-tuning is modeled as a constrained optimization problem. The goal is to minimize task-specific loss while keeping safety loss below a threshold ($\epsilon_1$). Since original safety data is often proprietary, the framework accounts for the use of proxy safety datasets.
  2. Case II: Alignment Parameter Constraint: This strategy restricts the fine-tuned model's weights ($\theta$) to remain within a specific distance ($\epsilon_2$) of the original safe model ($\theta_s$).

The core contribution is the derivation of mathematical bounds on the "Safety Alignment Gap" (safety loss) and the "Capability Performance Gap" (performance sacrifice).

Experimental Setup

To validate the theoretical findings, experiments were conducted using the Llama-2-7B model. Several datasets were employed:

  • Orca: The primary alignment dataset representing the safety "gold standard."
  • Alpaca & Alpaca-GPT-4: Used as proxy safety datasets to test the impact of data similarity.
  • Commitpackft & Open-platypus: Capability-focused datasets for code generation and reasoning, respectively.

Key Results and Insights

The Impact of Context Overlap

A central finding is the role of "context overlap." When fine-tuning data and safety data cover similar linguistic patterns or topics, the model faces a conflict between being helpful and being safe. Experiments showed that fine-tuning on Commitpackft (code) resulted in a significantly better trade-off than Alpaca because code has minimal context overlap with general safety instructions.

Trade-off curves showing the relationship between safety alignment loss gap and capability loss gap for different fine-tuning datasets.

Proxy Quality and Distribution Mismatch

The similarity between the proxy safety data and the original alignment data is crucial. Using Alpaca-GPT-4 as a proxy mitigated safety loss more effectively than standard Alpaca, confirming that distribution mismatch is a primary driver of the safety gap.

Comparing Constraint Strategies

The study reveals that loss-based constraints (Case I) consistently outperform parameter-based constraints (Case II). Parameter constraints act as a "blunt instrument," significantly hindering the model's ability to learn new tasks for any given level of safety preservation.

Comparison of the safety-capability trade-off between loss-based constraints (Case I) and parameter-based constraints (Case II).

Conclusion

This work establishes that the safety-capability trade-off is a fundamental property of LLM fine-tuning governed by data distribution and constraint types. While loss-based constraints offer a more flexible balance, the "context overlap" between task and safety data remains a critical bottleneck. Future research will aim to extend this framework to Reinforcement Learning from Human Feedback (RLHF) and explore dynamic safety mechanisms that adapt alongside new capabilities.

Summary updated

BibTeX
@misc{chen2025fundamental,
  author = {Pin-Yu Chen and Han Shen and Payel Das and Tianyi Chen},
  title = {{Fundamental Safety-Capability Trade-offs in Fine-tuning Large Language Models}},
  year = {2025},
  eprint = {2503.20807},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.20807},
}
Figure