Prompt Generation Networks for Efficient Adaptation of Frozen Vision Transformers

Jochem Loedeman, Maarten C. Stol, Tengda Han, Yuki M. Asano · DOI

Introduction

As computer vision models scale to billions of parameters, such as ViT-22B, traditional full fine-tuning becomes computationally prohibitive. Moreover, the rise of model-as-a-service APIs means users often lack access to internal weights, necessitating non-invasive adaptation techniques. Visual Prompting emerged as a solution, where learnable "pixels" are added to the input to steer a frozen model. However, existing methods typically use static prompts—the same for every image—which limits flexibility and performance.

Prompt Generation Networks (PGNs) address this by generating unique, image-specific visual prompts for every input. This approach maintains the efficiency of prompting while achieving performance comparable to full fine-tuning.

Methodology: The PGN Architecture

The PGN framework introduces a dynamic mechanism to generate input-dependent prompts using three core components: a lightweight backbone, a Token Library, and a prompt generation head.

Overview of the PGN architecture showing the integration with a frozen Transformer and the internal Token Library mechanism.

Lightweight Backbone and Token Library

Instead of processing the entire high-resolution image through a heavy network, PGN uses a small backbone (e.g., ResNet-10) to extract global features. To avoid the high parameter cost of generating high-dimensional prompt vectors directly, PGN utilizes a Token Library—a set of $N$ learnable feature vectors. The network outputs a probability distribution (via softmax) to select and linearly combine these tokens, creating a compact yet expressive representation.

Prompt Inversion for Black-Box Adaptation

A significant challenge in visual prompting is adapting models hosted behind APIs where only RGB inputs are accepted. PGN addresses this via a "Prompt Inversion" trick. By using the pseudo-inverse of the frozen model's first linear layer, latent-space prompts are mapped back into the RGB input space. These generated patches are then appended to the original image.

Visualization of the Prompt Inversion trick, showing generated prompts appended as RGB patches.

Experimental Evaluation

The researchers evaluated PGNs across 12 diverse datasets, including general (CIFAR), specialized (Oxford Flowers, Pets), satellite (EuroSAT), and reasoning (CLEVR) tasks. The primary backbone used was a ViT-B/32 pretrained with CLIP.

Key Results

  • Performance: PGNs outperformed static visual prompting on all 12 datasets. On average, they achieved 86.9% accuracy, matching full fine-tuning while updating approximately 100x fewer parameters.
  • State-of-the-Art: PGNs exceeded full fine-tuning performance on 5 datasets, including Food101 and EuroSAT.
  • Efficiency: By using a ResNet-10 backbone, the PGN adds only 1M–5M parameters, making it highly efficient for adapting massive models.

Discussion and Insights

Qualitative analysis suggests a "division of labor": the frozen ViT handles general feature extraction, while the PGN provides orthogonal cues—such as lighting or geometric context—that help the model focus on task-relevant information. Furthermore, PGNs demonstrate automatic domain discovery; when trained on mixed datasets, the generated prompts naturally cluster by domain without explicit supervision.

Limitations

While PGNs are efficient for inference, they currently require gradient information from the frozen model during training. This implies that for API-based deployment, the provider must support gradient return or the user must possess a local proxy of the model. Future work will explore PGNs for video tasks and multi-dataset settings.

Summary updated

BibTeX
@inproceedings{loedeman2024prompt,
  author = {Jochem Loedeman and Maarten C. Stol and Tengda Han and Yuki M. Asano},
  title = {{Prompt Generation Networks for Efficient Adaptation of Frozen Vision Transformers}},
  booktitle = {BMVC},
  year = {2024},
}
Figure