Back to research

LASP: Text-to-Text Optimization for Language-Aware Soft Prompting of Vision & Language Models

Adrian Bulat, Georgios Tzimiropoulos

IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2023 · pp. 23232–23241

Abstract

Soft prompt learning has recently emerged as one of the methods of choice for adapting V&L models to a downstream task using a few training examples. However, current methods significantly overfit the training data, suffering from large accuracy degradation when tested on unseen classes from the same domain. To this end, in this paper, we make the following 4 contributions: (1) To alleviate base class overfitting, we propose a novel Language-Aware Soft Prompting (LASP) learning method by means of a text-to-text cross-entropy loss that maximizes the probability of the learned prompts to be correctly classified with respect to pre-defined hand-crafted textual prompts. (2) To increase the representation capacity of the prompts, we propose grouped LASP where each group of prompts is optimized with respect to a separate subset of textual prompts. (3) We identify a visual-language misalignment introduced by prompt learning and LASP, and more importantly, propose a re-calibration mechanism to address it. (4) We show that LASP is inherently amenable to including, during training, virtual classes, i.e. class names for which no visual samples are available, further increasing the robustness of the learned prompts. Through evaluations on 11 datasets, we show that our approach (a) significantly outperforms all prior works on soft prompting, and (b) matches and surpasses, for the first time, the accuracy on novel classes obtained by hand-crafted prompts and CLIP for 8 out of 11 test datasets.

Key contributions

  1. Language-aware supervision

    Add a text-to-text cross-entropy loss that aligns learned prompts with handcrafted textual prompts and reduces overfitting to the base classes.

  2. Grouped prompt learning

    Train groups of soft prompts against separate subsets of textual templates to increase the capacity of the prompt representation.

  3. Visual–language re-alignment

    Fine-tune the visual encoder’s Layer Normalization and learn a class-agnostic correction bias, while keeping the text encoder frozen.

  4. Learning with virtual classes

    Include class names without corresponding training images in the language-only loss to improve generalization to unseen classes.

Code and benchmarks

The released LASP repository provides PyTorch training code built with Dassl.pytorch, setup instructions, dataset preparation tools and evaluation logs. Its setup guide links to the benchmark preparation instructions.

The paper evaluates base-to-novel class generalization on 11 benchmarks: ImageNet, Caltech101, Oxford Pets, Stanford Cars, Flowers102, Food101, FGVC Aircraft, SUN397, DTD, EuroSAT and UCF101.

Citation

If you use this work, please cite:

@inproceedings{bulat2023lasp,
  title={LASP: Text-to-Text Optimization for Language-Aware Soft Prompting of Vision \& Language Models},
  author={Bulat, Adrian and Tzimiropoulos, Georgios},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={23232--23241},
  year={2023}
}
Watch the video demonstration
Watch the video