Learning Visual Prompts for Guiding the Attention of Vision Transformers
Razieh Rezaei, Masoud Jalili Sabet, Jindong Gu, Daniel Rueckert, Philip Torr, Ashkan Khakzar
TL;DR
Addresses guiding vision transformer attention without fine-tuning by learning a visual patch prompt via self-supervision. The method inserts a learnable patch $P$ produced by a neural prior into input images and optimizes $L_{KL}$ to align last-layer attention with a Gaussian target map $G(x,y)$ in token space. It demonstrates cross-encoder applicability to CLIP, SigLIP, DeiT, and DINOv2, achieving improvements on CUB keypoint naming and competitive results on RefCOCO while revealing shape and scale effects on attention steering. This framework offers a practical path to adapt future vision-language models to spatial prompts without dataset-bias priors or supervised finetuning.
Abstract
Visual prompting infuses visual information into the input image to adapt models toward specific predictions and tasks. Recently, manually crafted markers such as red circles are shown to guide the model to attend to a target region on the image. However, these markers only work on models trained with data containing those markers. Moreover, finding these prompts requires guesswork or prior knowledge of the domain on which the model is trained. This work circumvents manual design constraints by proposing to learn the visual prompts for guiding the attention of vision transformers. The learned visual prompt, added to any input image would redirect the attention of the pre-trained vision transformer to its spatial location on the image. Specifically, the prompt is learned in a self-supervised manner without requiring annotations and without fine-tuning the vision transformer. Our experiments demonstrate the effectiveness of the proposed optimization-based visual prompting strategy across various pre-trained vision encoders.
