TL;DR
SAMPLe (Sharpness-Aware Minimization Prompt Learning) is a novel, model-agnostic optimizer designed to overcome the performance-generalization dilemma in Vision-Language Models (VLMs). By dynamically balancing the exploitation of low training loss with the exploration of a flatter loss landscape, SAMPLe prevents learnable prompts from overfitting to seen data. It seamlessly plugs into existing prompt-learning frameworks, consistently outperforming state-of-the-art optimizers across diverse generalization tasks.
What Problem Does This Paper Address?
Pre-trained Vision-Language Models (VLMs) like CLIP are incredibly powerful foundation models, but adapting them to specific downstream tasks efficiently remains a challenge. Prompt learning has emerged as a popular solution, tuning a small set of continuous vectors (prompts) while keeping the massive underlying VLM parameters frozen.
However, prompt learning suffers from a severe performance-generalization dilemma. Because the learnable parameter space is so small, the optimization process is highly sensitive and prone to getting trapped in sharp, high-curvature minima within the loss landscape. While these prompts achieve high accuracy on the training data (seen distributions), they overfit heavily and generalize poorly to unseen data or novel classes.
Existing sharpness-aware optimization methods (like vanilla SAM) attempt to find flatter minima by perturbing parameters, but they often apply uniform updates that fail to balance task-specific accuracy with broad generalizability. They also suffer from "full-batch bias," where global gradient alignment suppresses the natural stochasticity needed to explore the loss landscape effectively.
Methods
To tackle this dilemma, the authors introduce SAMPLe, a plug-in sharpness-aware optimizer tailored specifically for VLM prompt learning.
SAMPLe introduces a dual-objective optimization framework that operates via three core strategies:
- Curvature Awareness: It optimizes simultaneously for low training loss and a flat loss landscape to ensure stability and robustness.
- Gradient Decomposition: SAMPLe breaks down the mini-batch gradient into two components: a global trend aligned with the full-batch gradient (approximated using an Exponential Moving Average) and a batch-specific orthogonal gradient ($\nabla^{\mathcal{B}}L$).
- Dynamic Alignment Constraints: Instead of rigidly enforcing adversarial maximization like vanilla SAM, SAMPLe constrains the gradient updates at the perturbed point to align with the batch-specific gradient (orthogonal to the full-batch gradient).
Unlike conventional methods that rely on static, heuristic hyperparameter tuning, SAMPLe dynamically adjusts its gradient updates across different stages of optimization (early, middle, and late) based on local curvature and gradient properties.
Datasets
The authors evaluated SAMPLe across 11 diverse, publicly available image classification datasets for downstream tasks:
- General & Fine-Grained Classification: ImageNet, Caltech101, OxfordPets, StanfordCars, Flowers102, Food101, FGVCAircraft, SUN397, DTD, EuroSAT, and UCF101.
- Cross-Domain Generalization: To test robustness against distribution shifts, the model was trained on ImageNet and exclusively evaluated on four distinct target domain variants: ImageNetV2, ImageNet-Sketch, ImageNet-A, and ImageNet-R.
Key Insights and Ideas
- Full-Batch Bias is a Generalization Killer: When sharpness-aware perturbations align too closely with the global full-batch gradient, they smooth out the loss landscape excessively. This suppresses the helpful stochastic variability of mini-batches, causing the model to converge back into sharper minima.
- Orthogonality Breeds Exploration: By forcing the perturbed gradient to be orthogonal to the full-batch gradient, SAMPLe isolates batch-specific features. This allows the optimizer to aggressively explore flatter regions without sacrificing the exploitation of the primary training objective.
- Flatter Landscapes Don't Have to Cost Accuracy: Traditional wisdom suggests a trade-off where flatter landscapes reduce accuracy on seen distributions. As visualized in the paper's loss landscapes, SAMPLe successfully achieves both a flatter minimum and a lower empirical risk simultaneously.
Key Results
SAMPLe was integrated into five state-of-the-art prompt learning frameworks: CoOp, CoCoOp, MaPLe, TCP, and Co-Prompt.
- Base-to-New Generalization: SAMPLe consistently boosted the Harmonic Mean (HM) of base (seen) and novel (unseen) class accuracies. On average, CoOp's HM improved from 77.65 to 78.88, CoCoOp from 78.28 to 79.51, and MaPLe from 79.96 to 80.28.
- Cross-Dataset Transfer: When trained on ImageNet and tested directly on 10 unseen datasets, CoOp + SAMPLe improved average transfer accuracy from 63.88% to 65.85%, showing massive gains on high domain-shift datasets like FGVCAircraft (23.61% vs 18.47%).
- Robustness to Hyperparameters: Ablation studies showed that SAMPLe is highly robust to variations in the perturbation radius ($\rho$) and the gradient smoothing factor ($\lambda$), maintaining high accuracy and low variance where other optimizers faltered.
Limitations and Future Work
The paper primarily focuses on evaluating SAMPLe within image classification and domain generalization tasks using vision-language models like CLIP. The authors note that while sharpness-aware minimization has found success in single-modality fields, its potential remains insufficiently explored in broader multi-modal architectures. Future work could extend SAMPLe to more complex multimodal tasks such as visual question answering (VQA), image captioning, or video-language understanding.
Summary updated