Prompt Diffusion Robustifies Any-Modality Prompt Learning

Yingjun Du, Gaowen Liu, Yuzhang Shang, Yuguang Yao, Ramana Kompella, Cees G. M. Snoek · DOI

Abstract

Conventional prompt learning for foundation models often struggles with distributional shifts due to its reliance on static, deterministic prompts. We introduce Prompt Diffusion, a plug-and-play generative module that employs a diffusion process to refine and customize unique prompts for individual input samples. By treating prompts as a generative distribution rather than fixed vectors, our method significantly enhances robustness across text, vision, and multi-modal tasks. Experimental results across 15 datasets demonstrate that Prompt Diffusion consistently improves generalization and domain robustness with minimal inference latency.

Introduction

Foundation models like CLIP have transformed zero-shot classification through the use of prompts. While progress has been made from manual engineering to learned "soft" prompts (e.g., CoOp, MaPLe), these remains largely static. Such deterministic prompts frequently overfit to training data distributions, failing when encountering new domains or classes.

High-level overview of the Prompt Diffusion process, illustrating how refined prompts lead to more accurate classification probabilities.

To address this, we propose that prompts should be as dynamic as the data they describe. Prompt Diffusion treats prompts as points in a distribution reachable via a generative pathway, allowing for sample-specific adaptation that "robustifies" the underlying model.

Methodology

The Prompt Diffusion framework operates in two primary phases: training and inference.

Training Phase

  1. Per-Sample Overfitting: For each training image, we first optimize a prompt to minimize classification loss. This creates a set of "optima" prompts that serve as ground-truth targets for the generative model.
  2. Diffusion Transformer Training: A Diffusion Transformer is trained to map random noise to these optima prompts. This generation is conditioned on image features extracted by a lightweight "Meta-Net."

Testing Phase

At inference, the model lacks labels for overfitting. Instead, it utilizes the trained Diffusion Transformer to iteratively refine a customized prompt starting from random noise, conditioned on the test image's features. To maintain efficiency, we employ an ODE-based sampling strategy (AMED-Solver), achieving high-quality prompts in just five steps (~0.045s latency).

Detailed workflow of the Training and Testing phases in Prompt Diffusion, highlighting the per-sample overfitting and the iterative diffusion process.

Evaluation and Results

We evaluated Prompt Diffusion across 15 diverse datasets, including generic objects (ImageNet), specialized domains (EuroSAT, UCF101), and robustness benchmarks (ImageNet-A/R/SK).

Key Performance Metrics

  • Generalization: On 11 datasets, adding Prompt Diffusion to the CoPrompt baseline increased the harmonic mean accuracy from 80.48% to 82.96%.
  • Cross-Dataset Robustness: Average accuracy for the MaPLe baseline improved by 1.79% when trained on ImageNet and tested elsewhere.
  • Domain Adaptation: The method significantly bolstered performance on adversarial datasets like ImageNet-A, outperforming standard multi-modal methods.
  • Generative Architecture: Ablation studies confirmed that the diffusion-based approach outperforms GANs and VAEs by nearly 2% in harmonic mean accuracy.

Discussion

Prompt Diffusion represents a shift from deterministic to generative prompting. By using per-sample overfitting as a proxy for "perfect" prompts, the model learns a robust distribution of descriptions. As a "meta-plugin," it is modality-agnostic, enhancing text (CoCoOp), visual (VPT), or multi-modal (MaPLe) prompt learning.

While the approach introduces some training overhead due to the overfitting stage, the inference speed remains practical for most applications. Future work will explore scaling this generative mechanism to larger foundation models and high-throughput video processing environments.

Summary updated

BibTeX
@misc{du2024prompt,
  author = {Yingjun Du and Gaowen Liu and Yuzhang Shang and Yuguang Yao and Ramana Kompella and Cees G. M. Snoek},
  title = {{Prompt Diffusion Robustifies Any-Modality Prompt Learning}},
  year = {2024},
  eprint = {2410.20164},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.20164},
}
Figure