Paper commentary
Visual Prompt Tuning
Prompt vectors can adapt frozen vision Transformers almost as well as full fine-tuning
- Problem Full fine-tuning updates the whole backbone, so every downstream task needs its own stored copy of a large Transformer. Head-only, bias-only and adapter methods trail full fine-tuning in accuracy on these models.
- Method VPT, short for Visual Prompt Tuning, keeps the Transformer frozen and inserts learnable prompt vectors into the input sequence. It can add them at the first layer only or at every layer, and trains them with a linear head.
- Results VPT-deep beats full fine-tuning on 20 of 24 tasks with ViT-B/16, using 1.18× total parameters against 24.02× for full fine-tuning.
Why full fine-tuning is costly for large Transformers
Adapting a large pre-trained model to a new vision task usually means full fine-tuning, in which the whole backbone is updated end to end on that task. Each task then needs its own stored copy of the backbone, which becomes a heavy burden for Transformers because they are much larger than ConvNets. The gap is concrete: ViT-Huge has 632M parameters, while ResNet-50 has 25M.
Head-only tuning, bias-only tuning and residual adapters were developed for ConvNets and can be carried over to Transformers, but in general they trail full fine-tuning in accuracy. Rather than changing the Transformer's own weights, the authors change what is fed into it. The open question is whether this input-side route can rival full fine-tuning on vision Transformers, a setting in which prompting has not been studied.
Learnable prompts in the input sequence
VPT takes its cue from prompting in NLP, where a task is specified through continuous vectors that are tuned by gradients rather than through hand-written text. Here the vectors are learnable embeddings placed in the image token sequence, while the Transformer weights stay fixed. The image is cut into m fixed-size patches, and each patch is embedded into a d-dimensional space with positional encoding.
A learnable [CLS] token joins the sequence, and the classification head reads the final [CLS] embedding.
VPT-shallow inserts p prompt vectors after the embedding and only at the input of the first layer. Those prompts move through the later layers as features Z_i next to the [CLS] token and the patch tokens, and the head still reads the final [CLS] output. Because the prompts come after the positional encoding, putting them before or after the patch tokens leaves the final [CLS] output mathematically the same.
VPT-deep gives every layer its own fresh set of learnable prompts at that layer's input. Training updates only these prompts and the linear head, so what is stored for each task is the prompts plus the head.
ViT-B/16 results on FGVC and VTAB-1k
The main comparison adapts ViT-B/16 pre-trained on supervised ImageNet-21k to 5 FGVC tasks and to 19 VTAB-1k tasks in three groups, Natural, Specialized and Structured. Each method is scored by average test accuracy per group, and wins are counted against full fine-tuning in each group.
VPT-deep averages 89.11 on FGVC against 88.54 for full fine-tuning, and 78.48 on VTAB-Natural against 75.88. The largest gap is on VTAB-Structured, where VPT-deep averages 54.98 against 47.64 and wins on all 8 tasks in the group. On VTAB-Specialized the average runs the other way, with VPT-deep at 82.43 against 83.36, although it still wins on 2 of the 4 tasks.
Across the 24 tasks VPT-deep beats full fine-tuning on 20, and by group averages it is ahead in three of the four groups. In the Total params column VPT-deep is at 1.18× against 24.02× for full fine-tuning.
Among the parameter-efficient baselines, Bias is the closest on the FGVC average at 88.41, while Linear reaches 79.32 and Adapter 85.66. VPT-shallow reaches 84.62 on FGVC and 76.81 on Natural, ahead of Linear and Partial-1 on the Natural and Specialized averages. VPT-deep is above every other parameter-efficient protocol in the table on each group average, which the authors read as evidence that VPT-deep is the stronger choice when storage is limited.
Training data size and backbone size
The FGVC data-scale study varies the training fraction from 10% to 80%. Methods with fewer trainable parameters, including VPT, Linear, Adapter and Bias, beat full fine-tuning when data is scarce. As more data arrives, Linear and Adapter fall behind full fine-tuning, while VPT-deep stays ahead at every data size. Bias is close to VPT-deep but is still slightly below it at each size.
Across ViT-B, ViT-L and ViT-H, VPT-deep beats Linear and VPT-shallow in all three VTAB groups. Against full fine-tuning, the authors report that VPT-deep stays ahead on Natural and Structured as the model grows and is nearly equal on Specialized.
Swin-B and hierarchical Transformers
The experiments use Swin-B pre-trained on supervised ImageNet-21k.
Full fine-tuning scores 79.10 on Natural, 86.21 on Specialized and 59.65 on Structured. VPT-deep scores 76.78, 84.53 and 53.35 on those groups, so it stays below full fine-tuning in each one and full fine-tuning gives the highest overall accuracy. VPT-shallow reaches 79.85 on Natural, which is above full fine-tuning on that group. The authors find it surprising that the gap between VPT-deep and VPT-shallow shrinks on Natural.
Self-supervised ViT backbones
With MAE pre-training on ViT-B, full fine-tuning scores 59.29 on VTAB-Natural, VPT-deep scores 36.02 and VPT-shallow 39.96, while the Linear head scores 18.87. Both VPT variants clear the Linear head, but Partial-1, at 58.44 on that group, is the strongest parameter-efficient method there. With MoCo v3 pre-training, full fine-tuning scores 71.95 on Natural, VPT-deep scores 70.27 and Partial-1 scores 72.31, so VPT-deep is not the best method on that objective.
The authors say these self-supervised ViTs differ fundamentally from the supervised ones and leave the reasons open.
Semantic segmentation on ADE20K
Prompts are inserted only into the ViT encoder, and the decoder sees only the image patch embeddings, so prompt outputs are dropped before decoding. For VPT, the learning rate multiplier is set to 1.0 instead of the default 10.0, and the learning rate is 0.005 for all methods.
Single-scale mIoU is 48.31 for full fine-tuning, 35.12 for head-only tuning, 43.40 for Bias, 42.11 for VPT-deep and 44.04 for VPT plus Bias. Multi-scale mIoU is 50.07 for full fine-tuning, 45.33 for Bias, 44.06 for VPT-deep and 45.63 for VPT plus Bias. Trainable parameters are 13.43M for VPT-deep, 15.79M for VPT plus Bias and 318.31M for full fine-tuning, and the fully fine-tuned ResNet-101 reference has 63.0M with 45.47 single-scale mIoU.
The authors conclude that the parameter-efficient protocols do not match full fine-tuning here, but VPT stays comparable to Bias.
Applying the prompts to ConvNets
For ConvNets the prompts are learnable pixels added around the image, padding height and width, with the prompt length p chosen from 1, 3, 5, 7, 9 and 11. The authors use this because there is no obvious way to add location-invariant prompts to a ConvNet as there is for a Transformer.
On ConvNeXt-Base, VPT scores 78.48 on Natural against 77.97 for full fine-tuning, 83.00 against 83.71 on Specialized, and 44.64 against 60.41 on Structured. On ResNet-50, VPT scores 66.25 on Natural against 59.72 for full fine-tuning, 77.32 against 76.66 on Specialized, and 37.52 against 54.08 on Structured. The total parameter ratios are 1.02× for ConvNeXt-Base and 1.09× for ResNet-50.
Where, how many and how deep to put prompts
Besides the default prepending in the embedding space, the study tries adding prompts element-wise to the patch embeddings, which keeps the sequence length unchanged. Adding is competitive with full fine-tuning on some groups but generally falls behind prepending in both the deep and the shallow settings. Placing shallow prompts in pixel space with Prepend-pixel lowers VTAB-Natural accuracy by 6.9 points relative to the embedding-space default.
Concat-channel, which adds a new channel to the input image, drops accuracy by as much as 30 points on VTAB-Natural. The authors read this as evidence that prompts learn more useful signals in the latent input space of the Transformer.
Prompt length is the only extra hyperparameter of VPT, and the search over {1, 5, 10, 50, 100, 200} was guided by the validation set. The best length varies by task, and even one prompt lets VPT-deep beat the Mlp and Adapter baselines on their own tuned hyperparameters.
Performance rises with prompt depth in general, and inserting prompts from the top layers down to the bottom layers reduces accuracy. The authors infer that prompts at earlier layers matter more than prompts at later layers. For the final output, average pooling over the image patch outputs gives 82.3 against 82.4 for the [CLS] default on VTAB-Specialized, while pooling that includes the final prompt outputs can drop accuracy by as much as 8 points.
Do the learned prompts or the longer sequence explain the gain?
Prompt-Fixed keeps the prompts frozen during fine-tuning, while Prompt-Learned updates them and [CLS]-Learned updates only the [CLS] token. Frozen prompts give results comparable to a linear head, whereas learning the prompts gives significant gains, which suggests the learned prompt embeddings drive most of the performance. Updating only the [CLS] token performs about as well as one learned prompt but still trails the default setting with the chosen prompt length.
Sharing one prompt embedding within each layer gives results close to a single prompt, and sharing across layers slightly outperforms the default VPT-deep with a similar parameter count. Sharing across all prompts deteriorates accuracy but still beats linear probing on the three VTAB groups.
Statistical tests across VTAB tasks
A paired one-tailed Wilcoxon signed-rank test uses averaged accuracies over 5 runs for the 19 VTAB tasks, with the alternative that VPT-deep scores higher. The p-values are below 0.05 for every compared protocol, for example 1.2e-03 against full fine-tuning and 1.9e-06 against Mlp-3.
A Welch unequal-variance test compares the individual runs for each VTAB task, with 5 observations per run set. It rejects the null in 127 of 152 comparisons (19 tasks by 8 baselines), and against full fine-tuning VPT-deep is significantly better on 11 of 19 tasks.
Input resolution
At 384 resolution VPT-deep scores 79.37 on Natural, 82.86 on Specialized and 56.36 on Structured, against 72.57, 83.05 and 50.86 for full fine-tuning at 384. At 224 resolution with p = 380, VPT-deep reaches 74.20, 82.30 and 54.50 on the three groups, which the authors describe as similar to full fine-tuning at 384 with far fewer trainable parameters.
Training and inference cost
Costs were measured with ViT-B/16 on an A100 GPU, batch size 64 for both training and inference. Full fine-tuning takes 358.7 ms per image to train with 11.7 GB peak memory, and 69.7 ms with 0.87 GB at test time. VPT-deep with p = 1 trains at 213.6 ms per image with 10.3 GB and tests at 69.4 ms with 0.88 GB. VPT-deep with p = 200 trains at 360.1 ms per image with 25.8 GB and tests at 140.8 ms with 1.85 GB.
Doubling the sequence, with p = 200 against m = 198, costs about 2× rather than the 4× that quadratic attention scaling would predict, for both inference latency and peak memory relative to full fine-tuning. A prefix form of VPT, which prepends the prompts to the keys and values inside self-attention, reduces test latency and peak memory at large p without the accuracy change seen on VTAB.
Limitations
On Swin-B the advantage of VPT-deep over full fine-tuning does not hold on the overall VTAB comparison, where full fine-tuning is highest. On ViT-B/16 the Specialized average also favours full fine-tuning, and on MoCo v3 pre-training VPT-deep is not the best method. Parameter-efficient protocols do not match full fine-tuning on ADE20K segmentation, which was tested only with SETR-PUP on ViT-L.
Long prompts add latency: VPT-deep with 200 prompts tests at 140.8 ms per image against 69.7 ms for full fine-tuning. The authors leave open why MAE and MoCo v3 backbones behave differently from the supervised ones.
Paper info
- Authors
- Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, Ser-Nam Lim
- Venue
- arXiv · Preprint
- First published
- 2022-3-23
- Added
- 2026-11-12
- Updated
- 2022-7-20
- Version
- v2
- arXiv
- 2203.12119
- Category
- cs.CV
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, Ser-Nam Lim (2022). Visual Prompt Tuning. arXiv:2203.12119v2. https://arxiv.org/abs/2203.12119v2
BibTeX
@misc{jia2022visual,
title = {{Visual Prompt Tuning}},
author = {Menglin Jia and Luming Tang and Bor-Chun Chen and Claire Cardie and Serge Belongie and Bharath Hariharan and Ser-Nam Lim},
year = {2022},
eprint = {2203.12119},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2203.12119v2}
}