Abstract
Sharpness-Aware Minimization (SAM) has emerged as a powerful technique for improving the generalization of deep neural networks by seeking flatter minima in the loss landscape. However, the bilevel optimization structure of SAM complicates data attribution—the process of identifying which training samples most influence a model's predictions. This paper introduces two novel influence function methods, SAM-HIF and SAM-GIF, designed to accurately trace data influence in SAM-trained models. Our results demonstrate that these methods provide significant computational speedups over retraining while maintaining high fidelity, enabling efficient model editing and noise detection.
Introduction
Deep neural networks are notoriously prone to memorizing noisy or mislabeled training data, a phenomenon that often degrades their ability to generalize to unseen examples. To mitigate this, researchers frequently employ Sharpness-Aware Minimization (SAM). SAM improves generalization by navigating the loss landscape to find "flat" minima, where the loss remains low even under small parameter perturbations. This is achieved through a bilevel (minimax) optimization process: an inner loop identifies a perturbation that maximizes local loss, and an outer loop updates model parameters to minimize this worst-case loss.
While SAM is effective, it introduces a significant challenge for interpretability. Data attribution—determining how specific training points affect a model's final state—is typically handled by Influence Functions (IF). However, standard IFs are designed for standard loss minimization and fail to account for SAM's inner-loop perturbations. Removing a single data point in SAM doesn't just change the gradient; it changes the very perturbation used to calculate that gradient. This paper addresses this gap by redesigning influence functions specifically for the SAM architecture.
Methodology
The authors propose two distinct data valuation methods tailored for different computational and practical constraints:
1. SAM-HIF (Hessian-based Influence Function)
SAM-HIF is a closed-form mathematical measure that calculates influence based on the final trained model weights. Unlike traditional methods, SAM-HIF explicitly models how a specific data point influences the model's local sharpness. To overcome the massive computational cost of calculating and inverting the Hessian matrix, the authors utilize a Neumann Series Approximation to efficiently compute the inverse Hessian-vector product (iHVP).
2. SAM-GIF (Gradient Trajectory-based Influence Function)
In practical applications, SAM often uses approximations for the worst-case perturbations to save time. SAM-HIF, which assumes an idealized exact perturbation, can occasionally diverge from the actual training behavior. To solve this, the authors introduced SAM-GIF. Instead of relying on the final Hessian, SAM-GIF uses saved model checkpoints to trace the actual gradient descent trajectory during training. By accumulating the influence of a data point over the entire training path, SAM-GIF bypasses heavy Hessian computations and more accurately reflects the optimizer's actual behavior.
Experimental Evaluation
The methods were evaluated across a diverse suite of image classification datasets, including CIFAR-10, CIFAR-100, MiniImageNet, MNIST, HAM10000 (medical skin lesions), and fine-grained sets like CUB and FOOD-101 using ResNet-50 architectures.
Key Results
- Efficiency and Speed: The computational gains are substantial. On the CIFAR-10 dataset using a WideResNet model, the gold standard of "leave-one-out" retraining takes approximately 3516 seconds. SAM-HIF reduces this to 41 seconds, while SAM-GIF slashes the time to just 4.9 seconds.
- High Fidelity: Despite the speed, the accuracy of the attribution remains high. SAM-GIF achieved a fidelity score of 0.9497, nearly indistinguishable from the 0.9500 achieved through full retraining.
- Mislabeled Data Detection: In experiments where 10% of labels were intentionally flipped, SAM-GIF successfully identified over 90% of the noisy data points. Removing these points based on their influence scores led to a steady improvement in test accuracy.
- Model Editing: These functions allow for "surgical" model updates. If harmful data is discovered post-training, its influence can be mathematically subtracted from the model weights in seconds, avoiding the need for a full retraining cycle.
Discussion and Limitations
The research highlights a critical "bilevel bottleneck" in data attribution: a data point's influence in SAM is indirect, mediated through the perturbation step. The authors demonstrate that tracking the historical gradient trajectory (SAM-GIF) is often superior to analyzing the final state (SAM-HIF), as it captures the actual path taken by the optimizer.
However, there are trade-offs. SAM-HIF relies on the assumption of optimal perturbations, which may not hold in all practical settings. Conversely, SAM-GIF requires the storage of multiple training checkpoints, which may present a storage challenge for exceptionally large models. Future work may focus on reducing the memory footprint of trajectory-based methods and extending these techniques to Large Language Models (LLMs), where SAM is increasingly utilized to bolster generalization.
Conclusion
SAM-HIF and SAM-GIF provide the first robust framework for data attribution in sharpness-aware training. By accounting for the unique geometry of the SAM loss landscape, these tools enable faster model debugging, more effective noise removal, and a deeper understanding of how specific data points contribute to model generalization.
Summary updated