δ-SAM: Sharpness-Aware Minimization with Dynamic Reweighting

Wenxuan Zhou, Muhao Chen

TL;DR

This paper introduces δ-SAM, a novel method that approximates the computationally expensive per-instance adversarial weight perturbations used in Sharpness-Aware Minimization (SAM) with a more efficient, dynamically reweighted per-batch approach. δ-SAM achieves comparable or better generalization performance than SAM across various NLP tasks, with only a marginal increase in computational cost.

What Problem Does This Paper Address?

Deep neural networks, especially when overparameterized, often struggle with generalization, meaning they perform poorly on unseen data. Adversarial training, which involves perturbing model inputs or weights to make them more robust, has shown promise in improving generalization. Sharpness-Aware Minimization (SAM) is a recent adversarial training technique that perturbs model weights to find "flat" minima in the loss landscape, which are empirically correlated with better generalization.

However, the most effective form of SAM involves per-instance weight perturbations, where each data point in a batch gets its own unique adversarial weight perturbation. This is computationally prohibitive due to the need for separate calculations for each instance, leading to a significant increase in training time and memory. The standard SAM implementation uses a single, per-batch perturbation, which is more efficient but less effective as it averages out the individual instance perturbations. This paper aims to bridge this gap by developing a method that approximates the benefits of per-instance perturbations without incurring their high computational cost.

Methods

The core innovation of this paper is δ-SAM (delta-SAM), which introduces a dynamic reweighting scheme to per-batch SAM. The authors' theoretical analysis reveals that the per-instance weight perturbation's effectiveness stems from prioritizing instances that cause a larger change in the loss gradient. δ-SAM leverages this insight by:

  1. Estimating Instance Weights: For each instance in a batch, δ-SAM estimates a weight based on its "gradient change rate." This is achieved by perturbing the model weights with random Gaussian noise and observing the resulting change in loss. This estimation requires a few extra forward passes per batch.
  2. Dynamic Reweighting: The batch is then reweighted based on these estimated instance weights. Instances that are more sensitive to weight perturbations (i.e., have a higher gradient change rate) are given more importance.
  3. Per-Batch Perturbation on Reweighted Batch: A single adversarial weight perturbation is calculated for the entire batch, but this calculation is performed on the reweighted batch loss. This effectively prioritizes the more influential instances.
  4. Model Update: The model is then updated using the original, unweighted loss with the calculated perturbation.

This approach aims to mimic the effect of per-instance perturbations by giving more "say" to the instances that matter most, all while using a single perturbation for the batch update.

Datasets

The paper evaluates δ-SAM on several natural language understanding (NLU) tasks:

  • GLUE Benchmark: A collection of diverse NLU tasks (MNLI, QQP, RTE, QNLI, MRPC, COLA, SST2, STS-B).
  • Self-supervised Semantic Textual Similarity (STS) tasks: Including SemEval 2012-2016, STS Benchmark, and SICK-Relatedness.
  • CNN/DailyMail: A dataset for abstractive summarization.

The authors use pre-trained language models like BERTBASE, ROBERTALARGE, BART, and Mirror-BERT/Mirror-RoBERTa as encoders for these tasks.

Key Insights and Ideas

  • The "Flatness" Connection: The paper reinforces the well-established link between finding flat minima in the loss landscape and achieving better model generalization. SAM is a prime example of this.
  • Per-Instance vs. Per-Batch Trade-off: The core problem addressed is the significant computational cost of per-instance SAM, which limits its practical application, versus the efficiency but lower effectiveness of per-batch SAM.
  • Dynamic Reweighting as a Bridge: The key insight is that by dynamically reweighting instances within a batch based on their gradient sensitivity, one can approximate the benefits of per-instance perturbations without the prohibitive cost. This is theoretically motivated by analyzing the gradient of the per-instance objective.
  • Efficiency Gains: δ-SAM achieves its approximation with only a small, manageable increase in computational cost (around 18% more than standard SAM) compared to the massive overhead of true per-instance SAM.

Key Results

  • Improved Generalization: δ-SAM consistently outperforms standard SAM across various GLUE, STS, and summarization tasks. For example, on the GLUE benchmark, δ-SAM improves BERTBASE and ROBERTALARGE by 1.8% and 1.2% respectively, outperforming SAM's improvements of 1.0% and 0.7%.
  • Competitive Performance: δ-SAM achieves comparable or better results than other state-of-the-art regularization methods on several tasks.
  • Reduced Adversarial Risk: δ-SAM demonstrates a smaller adversarial risk than SAM, indicating it's a better approximation of per-instance perturbation.
  • Marginal Computational Overhead: The paper reports that δ-SAM is only about 12% slower than SAM on average for the GLUE benchmark, a significant improvement over the much higher cost of per-instance SAM.

Limitations and Future Work

  • Computational Overhead: While more efficient than per-instance SAM, δ-SAM still introduces additional computational cost compared to standard training, which might limit its application on extremely large-scale training scenarios.
  • Further Improvements: The authors suggest that while δ-SAM consistently outperforms SAM, its performance is sometimes slightly lower than the full per-instance perturbation, indicating room for further refinement.
  • Future Directions: The authors propose exploring new techniques to further reduce the computational cost of δ-SAM and extending its effectiveness to other tasks like sequence tagging and question answering.

Summary updated

Abstract

Deep neural networks are often overparameterized and may not easily achieve model generalization. Adversarial training has shown effectiveness in improving generalization by regularizing the change of loss on top of adversarially chosen perturbations. The recently proposed sharpness-aware minimization (SAM) algorithm conducts adversarial weight perturbation, encouraging the model to converge to a flat minima. SAM finds a common adversarial weight perturbation per-batch. Although per-instance adversarial weight perturbations are stronger adversaries and can potentially lead to better generalization performance, their computational cost is very high and thus it is impossible to use per-instance perturbations efficiently in SAM. In this paper, we tackle this efficiency bottleneck and propose sharpness-aware minimization with dynamic reweighting (delta-SAM). Our theoretical analysis motivates that it is possible to approach the stronger, per-instance adversarial weight perturbations using reweighted per-batch weight perturbations. delta-SAM dynamically reweights perturbation within each batch according to the theoretically principled weighting factors, serving as a good approximation to per-instance perturbation. Experiments on various natural language understanding tasks demonstrate the effectiveness of delta-SAM.
BibTeX
@inproceedings{zhou2022sam,
  author = {Wenxuan Zhou and Muhao Chen},
  title = {{δ-SAM: Sharpness-Aware Minimization with Dynamic Reweighting}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.findings-emnlp.417},
}
Figure