AttriPrompt: Dynamic Prompt Composition Learning for CLIP

Qiqi Zhan, Shiwei Li, Qingjie Liu, Yunhong Wang

Introduction

Large vision-language models like CLIP have fundamentally changed the landscape of zero-shot learning. However, adapting these massive models to specific downstream tasks remains a challenge. Traditional "prompt tuning" methods, such as CoOp or PromptSRC, have attempted to solve this by learning "soft prompts"—sets of learnable vectors that replace manual templates like "a photo of a...".

Despite their success, these methods face two significant hurdles. First, they utilize static prompts, meaning the learned vectors remain identical regardless of the specific visual content of an image. Second, they exhibit a high-level over-reliance, focusing on global contrastive alignment while often ignoring the fine-grained, low-level visual cues—such as textures or specific part shapes—that are essential for distinguishing between similar categories.

AttriPrompt addresses these limitations by introducing a mechanism that injects hierarchical visual information directly into the prompting process, creating a dynamic, content-aware adaptation framework.

Methodology

AttriPrompt introduces three core components designed to make prompt learning more responsive to visual context:

1. Attribute Retrieval Module

Inspired by human cognition, this module leverages the intermediate layers of CLIP’s vision encoder. Rather than relying solely on the final output, AttriPrompt clusters local visual features from these layers into "attribute features." These features act as queries to retrieve the most relevant learnable prompts from a pre-defined Prompt Pool. Consequently, the text encoder receives a unique prompt combination tailored to the specific attributes of the input image, whether it is a domestic animal, a vehicle, or a satellite view.

2. Dual-Stream Contrastive Learning

To ensure the model effectively utilizes this fine-grained information, the authors implement a secondary alignment head. This dual-stream approach forces the model to refine its features and focus on the newly introduced visual attributes that standard CLIP might overlook, ensuring a tighter alignment between specific visual cues and text descriptions.

3. Self-Regularization

A common risk in prompt tuning is overfitting to the small training set, which can diminish the model's original open-vocabulary capabilities. AttriPrompt mitigates this through an L1 regularization loss applied between the prompted features and the original, non-prompted CLIP features. This acts as a tether, preventing the specialized knowledge from drifting too far from the model's generalized foundations.

Experimental Evaluation

The researchers evaluated AttriPrompt across 11 diverse image recognition datasets, spanning generic objects (ImageNet, Caltech101), fine-grained categories (OxfordPets, StanfordCars, Flowers102, Food101, FGVCAircraft), and specialized domains (SUN397 for scenes, DTD for textures, EuroSAT for satellite imagery, and UCF101 for action recognition).

The model was tested in three distinct scenarios:

  • Base-to-Novel Generalization: Learning on a subset of classes and testing on unseen ones.
  • Cross-Dataset Evaluation: Training on one dataset and testing on others.
  • Domain Generalization: Handling distribution shifts, such as sketches or adversarial versions of ImageNet.

Key Insights and Results

Hierarchical Vision as a Resource

AttriPrompt demonstrates that the internal layers of the vision encoder—which capture edges, textures, and parts—contain vital information for building superior text prompts. Moving beyond the final encoder output allows for a much richer representation of the visual scene.

Dynamic Composition vs. Static Vectors

By treating prompts as a pool to be sampled from rather than a fixed sequence, the model gains a form of "visual common sense." It can compose a prompt specifically tuned to the attributes present in the current image, leading to more robust classification.

Performance and Efficiency

AttriPrompt achieved a new state-of-the-art on nearly all benchmarks. Notable results include:

  • Significant Gains: On the "novel" classes of the EuroSAT dataset, AttriPrompt improved accuracy by 7.37% over previous methods.
  • Generalization: In base-to-novel settings, it achieved an average Harmonic Mean (HM) of 81.09% across 11 datasets, surpassing the previous best of 79.97%.
  • Data Efficiency: The method is remarkably efficient; AttriPrompt with only 4-shot training (4 images per class) matched the performance of previous state-of-the-art methods using 16-shot training.

Limitations and Future Work

While AttriPrompt offers substantial performance gains, it introduces a slight computational overhead. The clustering and retrieval process increases training and inference time by approximately 8% and 5%, respectively. Additionally, the model's performance is sensitive to hyperparameters such as the size of the prompt pool and the number of clusters; an oversized pool can lead to the retrieval of redundant or noisy prompts.

Future research may explore extending this attribute-aware approach to other multi-modal architectures or utilizing it to improve the interpretability of vision-language models, providing clearer insights into the specific visual features the models prioritize during classification.

Summary updated

BibTeX
@inproceedings{zhan2025attriprompt,
  author = {Qiqi Zhan and Shiwei Li and Qingjie Liu and Yunhong Wang},
  title = {{AttriPrompt: Dynamic Prompt Composition Learning for CLIP}},
  booktitle = {ACM Multimedia},
  year = {2025},
}
Figure