Privacy-preserving Fine-tuning of Large Language Models through Flatness

Tiejin Chen, Longchao Da, Huixue Zhou, Pingzhi Li, Kaixiong Zhou, Tianlong Chen, Hua Wei

TL;DR

Fine-tuning Large Language Models (LLMs) with Differential Privacy (DP) typically forces a trade-off where privacy comes at the expense of significant accuracy loss. This paper introduces DP-Flat, a framework that bridges this gap by enforcing "flatness" in the model's loss landscape, allowing DP-trained models to achieve performance comparable to—and sometimes better than—non-private models.

What Problem Does This Paper Address?

Large Language Models are notorious for memorizing sensitive training data, such as emails and addresses, posing major privacy risks. While Differential Privacy (DP) techniques like DP-SGD provide a mathematical safeguard against this, they often lead to "generalization degradation"—a sharp drop in the model's ability to perform well on new data.

The authors identify a key reason for this: DP training tends to push models toward "sharp" local minima in the loss landscape. In these sharp regions, tiny perturbations in model weights (like the noise added for privacy) cause the loss to spike, leading to poor performance. The challenge is to maintain strict privacy guarantees while guiding the model toward "flatter" regions that are more robust to DP noise.

Figure 1 illustrates how DP training leads to a sharper loss landscape and a worse privacy-performance trade-off compared to normal training.

Methods

The authors propose DP-Flat, a holistic framework that promotes weight flatness across three different granularities:

  1. Within-layer flattening: They adapt Adversarial Weight Perturbation (AWP) for DP training. This technique uses a min-max optimization strategy to find the "worst-case" loss in a small neighborhood around the weights and then optimizes to minimize that worst case, effectively smoothing out local spikes.
  2. Cross-layer flattening: Recognizing that not all layers contribute equally to sharpness, they use a greedy sparse prefix-tuning algorithm. It uses a "flatness-aware indicator" to selectively apply prefix modules only to the layers that most improve the overall landscape flatness.
  3. Cross-model flattening: They employ knowledge distillation where a non-private "duplicate" model (trained normally) acts as a guide. A regularization term forces the DP-trained model's weights to stay close to the smoother weight space of the non-private counterpart.

Crucially, the paper also extends these ideas to black-box settings (where internal weights are inaccessible) by utilizing zeroth-order (ZO) optimization techniques like DPZero.

Figure 2. Our methods improve the flatness of weight loss landscape from three aspects: (1) Within-layer flattening, where a perturbation- aware min-max optimization is utilized to encourage the loss flatness within the weight space of each LLM layer. (2) Cross-layer flattening, where a sparse prefix-tuning algorithm guides layer selection with a flatness-ware indicator. (3) Cross-model flattening, where non-private prefixes are used to guide DP training through knowledge distillation regularization.

Datasets

The framework was evaluated across a diverse set of NLP tasks and models:

  • Text Classification (GLUE Benchmark): SST-2 (sentiment), MNLI and QNLI (sentence pair classification), QQP and TREC (topic classification).
  • Text Generation: E2E and DART (table-to-text generation).
  • Models: RoBERTa-base, BERT-base (encoder-only), and GPT-2 (decoder-only).

Key Insights and Ideas

  • Sharpness is the Enemy: The core "aha moment" is that the performance gap in DP models isn't just about the added noise, but about where the model converges. Sharp minima are inherently incompatible with the noise required for privacy.
  • Flatness as a Bridge: By explicitly optimizing for a flatter loss landscape, the model becomes naturally more resilient to the perturbations introduced by DP-SGD.
  • Multi-scale Approach: Flatness isn't just a local property of a single weight; it's a hierarchical issue involving individual layers, the interaction between layers, and the overall model trajectory.
  • Black-box Viability: The research proves that you don't need full "white-box" access to a model's internals to improve its private fine-tuning performance, which is vital for proprietary, closed-source LLMs.

Key Results

  • Closing the Gap: On the QNLI dataset, DP-Flat achieved performance similar to non-private full fine-tuning with a privacy budget of $\epsilon=3$. With a higher budget of $\epsilon=8$, it actually outperformed the non-private baseline.
  • Significant Gains: In white-box settings, DP-Flat improved accuracy by up to 8.39% on QNLI and at least 2.5% on SST-2 compared to standard DP prefix-tuning.
  • Robust Privacy: Membership Inference Attack (MIA) evaluations confirmed that these performance gains do not come at the cost of privacy; DP-Flat maintains the same low privacy risk as vanilla DP training.
  • Generative Success: For text generation (GPT-2 on DART), DP-Flat consistently outperformed other DP-trained methods, showing its versatility beyond simple classification.

Limitations and Future Work

  • Black-box Complexity: While effective, the performance gap between private and non-private models remains larger in black-box settings than in white-box ones.
  • Optimization Variance: The within-layer flattening component is difficult to apply in black-box scenarios because zeroth-order gradient estimation has high variance, which can destabilize the min-max optimization.
  • Future Directions: The authors suggest further research into stabilizing black-box optimization and exploring even more granular ways to enforce flatness in massive-scale models.

Summary updated

BibTeX
@misc{chen2024privacy,
  author = {Tiejin Chen and Longchao Da and Huixue Zhou and Pingzhi Li and Kaixiong Zhou and Tianlong Chen and Hua Wei},
  title = {{Privacy-preserving Fine-tuning of Large Language Models through Flatness}},
  year = {2024},
  eprint = {2403.04124},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.04124},
}
Figure