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

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

Abstract

Training Large Language Models (LLMs) with Differential Privacy (DP) usually comes at a steep cost to accuracy. This paper introduces DP-Flat, a framework that recovers this lost performance by forcing the model to find "flatter" regions in its loss landscape, bridging the gap between private and non-private models without compromising data security.

Introduction

When fine-tuning LLMs on sensitive data such as medical records or private emails, Differential Privacy (DP) techniques—most commonly DP-SGD—are employed to ensure the model does not memorize or leak specific training examples. However, the noise introduced by DP training typically leads to a significant drop in model accuracy compared to standard fine-tuning.

The authors identify a structural reason for this utility gap: loss landscape sharpness. In standard training, models tend to find "flat" minima where small weight perturbations do not significantly alter the output, leading to superior generalization. Conversely, the noise in DP training pushes models into "sharp" minima, making them brittle. DP-Flat is proposed as a holistic framework to force DP-trained models into these elusive flat regions.

Methodology

The DP-Flat framework promotes flatness at three distinct levels:

  1. Within-layer Flattening: Adapting Adversarial Weight Perturbation (AWP), the algorithm performs a "min-max" optimization during early training stages. It searches for worst-case noise to add to weights (maximizing loss) and then updates the model to minimize that worst-case loss, smoothing the local neighborhood.
  2. Cross-layer Flattening: Since layers contribute unequally to sharpness, a greedy selection process identifies which layers should receive trainable "prefixes." A "Prefix Sharpness" metric ensures only layers that help maintain a flat landscape are utilized.
  3. Cross-model Flattening: Using knowledge distillation, the DP-trained model is regularized to keep its weights close to a "twin" model trained without privacy constraints, guiding it toward high-performance regions.
Overview of the DP-Flat framework illustrating within-layer, cross-layer, and cross-model flattening techniques.

Experimental Evaluation

The framework was evaluated across a diverse range of NLP tasks, including text classification (SST-2, MNLI, QNLI, QQP, TREC) and text generation (E2E, DART). Experiments were conducted using RoBERTa-base, BERT-base, and GPT-2 models.

Key Insights and Results

Visual evidence confirms that DP-trained models possess significantly sharper loss landscapes than non-private counterparts, identifying sharpness as a primary culprit for the utility gap. By explicitly optimizing for flatness, the model becomes more robust to the noise inherent in DP training.

Comparison of loss landscape sharpness and accuracy/privacy metrics between DP and normal training.

Key results include:

  • Closing the Utility Gap: On the QNLI dataset, DP-Flat achieved performance similar to non-private full fine-tuning at $\epsilon = 3$. At $\epsilon = 8$, it outperformed non-private benchmarks.
  • Significant Accuracy Gains: Compared to standard DP prefix-tuning, DP-Flat improved accuracy by up to 8.39% on QNLI and at least 2.5% on SST-2.
  • Privacy Preservation: Membership Inference Attack (MIA) metrics demonstrate that flatness-seeking methods do not increase the risk of data leakage; the model remains as private as standard DP-SGD.

Conclusion

While DP-Flat introduces some computational overhead due to the AWP phase and greedy layer selection, it successfully mitigates the performance loss associated with private training. Future work will explore scaling these strategies to extremely large models like Llama-3 or GPT-4.

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