Abstract
As large-scale Pre-trained Models (PTMs) like CLIP are increasingly deployed via restricted APIs, the research community faces a "black-box" challenge: adapting these models to specialized tasks without access to internal weights or gradients. This paper presents a novel framework that bridges this gap using a hybrid spatial-frequency visual prompter and probabilistic output clustering. By leveraging Zeroth-Order Optimization with gradient surgery, the proposed method achieves state-of-the-art performance across 14 benchmark datasets while maintaining significantly lower computational overhead than existing auxiliary-encoder approaches.
Introduction
The paradigm of machine learning is shifting toward the use of massive, foundation models. However, many of these models are provided as "black boxes"—users can input data and receive predictions but cannot perform standard backpropagation. This creates a significant hurdle for transfer learning, particularly in domains with limited labeled data or distinct visual characteristics, such as medical imaging or satellite remote sensing.
Traditional visual prompting—adding learnable pixel-level perturbations to input images—has emerged as a potential solution. Yet, existing methods often rely on heavy auxiliary encoders or fail to capture the structural information necessary for complex domain shifts. This paper introduces a more efficient, encoder-free approach that optimizes prompts in both the spatial and frequency domains while refining the model's output distribution through probabilistic clustering.
Methodology
The proposed framework consists of two primary components designed to work within the constraints of a black-box API.
1. Spatial-Frequency Visual Prompter
Unlike previous methods that focus solely on pixel-level changes, this framework utilizes a dual-domain approach to modify input images. By avoiding an auxiliary encoder, the model remains lightweight and memory-efficient.
- Frequency-Domain Prompts: Using the Discrete Cosine Transform (DCT), the model manipulates low-frequency components. This allows the prompter to adjust the structural and global content of the image to better align with the PTM’s internal representations.
- Spatial-Domain Prompts: These handle fine-grained, pixel-level details and local perturbations.
- Adaptive Scaling: A sigmoid-gated parameter ($\sigma(\phi^s)$) is employed to automatically balance the influence of frequency versus spatial prompts, allowing the model to adapt its strategy based on the specific requirements of the target dataset.
2. Cluster-Based Prediction Refinement
Because the internal weights of the black-box model are inaccessible, the authors treat the model's output probabilities as a feature space. They implement a refinement strategy using KL-based k-means clustering and auxiliary simplex prototypes. This process re-maps the model's raw probability outputs into a more distinct and accurate classification space, effectively "tuning" the output without needing to modify the model's final linear layer.
3. Optimization via Gradient Surgery
To optimize the prompter without backpropagation, the framework uses Zeroth-Order Optimization (specifically SPSA-GC). To mitigate the inherent noise of gradient estimation in high-dimensional spaces, the authors introduce "Gradient Surgery." This technique identifies and resolves conflicting directions in estimated gradients, leading to more stable and faster convergence during training.
Experimental Results
The framework was evaluated on a comprehensive suite of 14 benchmark datasets, including natural images (ImageNet, Caltech101), specialized domains (EuroSAT, DTD), and structured tasks (CLEVR, SVHN).
Performance and Accuracy
The proposed method achieved an average accuracy of 72.5% across all benchmarks. This represents a substantial improvement over the previous state-of-the-art black-box method, BlackVIP (65.0%), and the standard CLIP zero-shot baseline (57.6%). Notably, on the Loc-MNIST benchmark—designed to test a model's ability to ignore "distractor" features—the spatial-frequency prompts demonstrated superior robustness.
Computational Efficiency
By removing the need for an auxiliary encoder, the proposed method is significantly leaner than its predecessors:
- Memory Usage: Consumed 2971MB of GPU memory, compared to 4223MB for BlackVIP.
- Training Speed: Achieved a 40% increase in training speed per iteration (2.24s vs. 3.75s).
Discussion and Insights
A key finding of this research is the importance of the frequency domain in transfer learning. For datasets like SVHN (street numbers), manipulating low-frequency components proved far more effective than spatial-only perturbations, as it helped the model capture the underlying structure of the digits. Furthermore, the success of the encoder-free approach suggests that making fewer assumptions about the data geometry of the black-box model can lead to better generalization.
Conclusion
This paper demonstrates that accurate and efficient transfer learning is possible even when the underlying model is a complete black box. By combining spatial-frequency prompting with output clustering and stabilized zeroth-order optimization, the authors provide a scalable path forward for utilizing restricted-access foundation models in specialized downstream tasks. Future work may extend these dual-domain prompting techniques to other modalities, such as video and audio processing.
Summary updated