Vision-language models (VLMs) like CLIP have revolutionized open-vocabulary tasks, yet their performance in few-shot scenarios remains hampered by the limitations of prompt tuning. Specifically, soft prompt learning is highly sensitive to initialization and prone to overfitting on the limited features of small support sets, leading to poor generalization across new domains. We introduce Gradient-RegulAted Meta-prompt learning (GRAM), a framework that addresses these challenges through a bi-level meta-learning paradigm. GRAM utilizes unlabeled web-scale image-text pairs to simulate diverse tasks via Cross-Modal Hierarchical Clustering (CHC). It learns a robust prompt initialization and a lightweight gradient regulator that filters update directions to prioritize domain-invariant features. Our comprehensive evaluation across 11 datasets demonstrates that GRAM significantly improves base-to-new generalization and cross-domain robustness, with our unified variant, UNIGRAM, achieving state-of-the-art performance.
Introduction
The emergence of large-scale vision-language models (VLMs) has shifted the paradigm of computer vision toward open-vocabulary recognition. While manual prompt engineering is effective, "soft prompt" tuning—learning continuous vectors in the embedding space—has emerged as a more efficient alternative. However, in few-shot settings, these methods suffer from two primary issues: initialization sensitivity and generalization degradation. Without a proper starting point, the optimization process is slow and inconsistent. Furthermore, the model often captures "spurious correlations" (e.g., background noise) from the few available training samples, causing a sharp drop in performance when applied to unseen classes or shifted domains.
Methodology
GRAM tackles these issues by "learning how to learn" prompts through meta-learning. The framework consists of two main components: a data generation strategy and a regulated optimization loop.
1. Cross-Modal Hierarchical Clustering (CHC)
To perform meta-learning without expensive human labels, GRAM leverages unlabeled web-scale data (e.g., CC3M). CHC first groups image-text pairs into semantic topics using BERT on the captions. Within each topic, it applies K-means clustering to visual features to identify distinct "domains." By sampling from these clusters, GRAM automatically generates thousands of meta-tasks that simulate real-world domain shifts, providing a rich training ground for the meta-learner.
2. Gradient-Regulated Meta-Learning
The meta-learning objective optimizes both a prompt initialization ($\theta$) and a gradient regulator ($R^\phi$). During the inner loop of meta-training, the model computes a gradient $g^s$ on a support set. The regulator $R^\phi$, a lightweight neural network, transforms $g^s$ into a regulated gradient $\hat{g}^s$. This regulated gradient is used to update the prompts. The outer loop then evaluates the updated prompts on a query set, updating both $\theta$ and $\phi$ to ensure that the regulated updates lead to better generalization. This process effectively "filters" the update direction, focusing on features that are consistent across the simulated domains.
3. UNIGRAM
The authors extend this concept to UNIGRAM, which applies gradient-regulated meta-learning to both the textual and visual branches of the VLM. This joint optimization allows the model to leverage multi-modal synergies, further enhancing robustness.
Results and Discussion
GRAM was evaluated on 11 diverse datasets, including ImageNet and various fine-grained benchmarks. A key finding is the stability of GRAM over time.
As shown in the training curves, standard prompt tuning (CoOp) often reaches a peak and then declines as it overfits the few-shot data. In contrast, GRAM's gradient regulation maintains high performance even with extended training. In base-to-new generalization tests, GRAM improved accuracy for unseen classes by an average of 1.82% for textual tuning and 1.87% for visual tuning. The unified UNIGRAM model achieved a harmonic mean (H) score of 78.07%, outperforming single-modality baselines. Furthermore, GRAM demonstrated superior robustness in cross-domain scenarios, such as testing on ImageNet-Sketch and ImageNet-R, where it consistently outperformed standard CoOp.
Conclusion
GRAM provides a scalable and effective solution for generalizable prompt tuning in vision-language models. By utilizing unlabeled web data to simulate domain shifts and introducing a gradient regulator to guide optimization, the framework overcomes the traditional pitfalls of few-shot learning. Future work may explore scaling this meta-learning approach to even larger datasets and more complex regulator architectures.
Summary updated