Source-linked AI summary

Tip-Adapter: Training-free Adaption of CLIP for Few-shot Classification

Renrui Zhang, Zhang Wei, Rongyao Fang, Peng Gao, Kunchang Li, Jifeng Dai, Yu Qiao, Hongsheng Li

arXiv:2207.09519v1cs.CVcs.AIcs.CL

TL;DR

Existing CLIP adaptation methods improve few-shot classification by fine-tuning additional modules, but require extra training and computation. Tip-Adapter instead retrieves few-shot knowledge through a cache model without training, while Tip-Adapter-F fine-tunes cached keys and achieves state-of-the-art performance with fast convergence.

  • Problem

    Existing methods improve CLIP’s few-shot classification performance through fine-tuning, but require extra training time and computational resources.

    Source: §1 · p. 2, §4.2 · p. 10
  • Method

    Tip-Adapter appends frozen CLIP with a non-parametric key-value cache model constructed from few-shot data, while Tip-Adapter-F unfreezes cached keys for fine-tuning.

    Source: §1 · p. 2, §3.1 · pp. 4, 6
  • Results

    Across 11 few-shot classification datasets, Tip-Adapter performs comparably to training-required approaches, while Tip-Adapter-F achieves state-of-the-art performance with super-fast convergence.

    Source: §1 · p. 3, §3.1 · p. 4, §6 · p. 14
  • Takeaways & Limitations

    Few-shot knowledge can be incorporated into CLIP through cache-based feature retrieval without conventional SGD-based training, with optional key fine-tuning for stronger performance.

    Source: §1 · p. 3, §3.1 · p. 6, §6 · p. 14

    Tip-Adapter-F keeps cache values and CLIP encoders frozen while learning cached keys, because the values encode ground-truth annotations.

    Source: §3.1 · p. 6

Abstract

from arXiv · show

Contrastive Vision-Language Pre-training, known as CLIP, has provided a new paradigm for learning visual representations using large-scale image-text pairs. It shows impressive performance on downstream tasks by zero-shot knowledge transfer. To further enhance CLIP's adaption capability, existing methods proposed to fine-tune additional learnable modules, which significantly improves the few-shot performance but introduces extra training time and computational resources. In this paper, we propose a training-free adaption method for CLIP to conduct few-shot classification, termed as Tip-Adapter, which not only inherits the training-free advantage of zero-shot CLIP but also performs comparably to those training-required approaches. Tip-Adapter constructs the adapter via a key-value cache model from the few-shot training set, and updates the prior knowledge encoded in CLIP by feature retrieval. On top of that, the performance of Tip-Adapter can be further boosted to be state-of-the-art on ImageNet by fine-tuning the cache model for 10$\times$ fewer epochs than existing methods, which is both effective and efficient. We conduct extensive experiments of few-shot classification on 11 datasets to demonstrate the superiority of our proposed methods. Code is released at https://github.com/gaopengcuhk/Tip-Adapter.

1 Introduction

Existing CLIP adaptation methods improve few-shot classification but require additional training, while Tip-Adapter introduces a training-free cache-based adapter and a fine-tuned variant for efficient adaptation.

  • CoOp and CLIP-Adapter improve CLIP for few-shot classification but require training additional learnable modules.Source: §1 · p. 2
  • Tip-Adapter appends weight-frozen CLIP with a non-parametric adapter built as a query-key cache model from few-shot data.Source: §1 · p. 2
  • The cache stores CLIP visual features as keys and one-hot labels as values for retrieving few-shot knowledge.Source: §1 · p. 3
  • During inference, similarity-based retrieval aggregates cached values into an adapter prediction, which is combined with CLIP’s original prediction through a residual connection.Source: §1 · p. 3
  • Tip-Adapter-F unfreezes cache keys for fine-tuning, achieves state-of-the-art ImageNet performance with fast convergence, and both variants are evaluated on 11 datasets.Source: §1 · p. 3

2 Related Work

Related work establishes CLIP as a source of transferable zero-shot features and describes additive-module adaptation and cache-based retrieval, positioning Tip-Adapter as a training-free alternative.

  • CLIP, DeCLIP, and ALIGN obtain transferable features for zero-shot recognition by learning from contrastive vision-language pairs.Source: §2 · p. 4
  • CoOp, CLIP-Adapter, and WiSE-FT improve CLIP with limited training data by freezing pretrained weights and training additive learnable modules.Source: §2 · p. 4
  • Tip-Adapter directly infuses few-shot supervision into pretrained CLIP in a training-free manner, targeting greater time and memory efficiency.Source: §2 · p. 4
  • A cache model stores training-image features and labels as key-value pairs and retrieves information through similarity-based aggregation without parameter updates.Source: §2 · p. 4

3 Method

Tip-Adapter adapts CLIP with a non-parametric cache built from few-shot visual features and labels, retrieving that knowledge during inference and combining it with CLIP’s prior predictions. Its fine-tuned variant updates cached keys while retaining frozen values and CLIP encoders, and the approach also relates visual and textual caches to prior adapter designs.

Training-free Adaption of CLIP

  • Tip-Adapter constructs a non-parametric key-value cache from few-shot CLIP visual features and one-hot ground-truth labels, avoiding extra training.The cached features serve as keys and the labels as values.Source: §3.1 · pp. 4–5
  • During inference, a test feature retrieves cached values through query-key similarities, producing an adapter prediction that is combined with CLIP’s original prediction by a residual connection.The similarity transformation uses φ(x) = exp(-β(1 − x)), with β controlling sharpness and α balancing the two predictions.Source: §3.1 · p. 6

Tip-Adapter with Fine-tuning

  • Tip-Adapter-F fine-tunes cached keys with SGD while freezing cached one-hot values and both pre-trained CLIP encoders.The keys are initialized from the cache model to improve affinity estimation without changing category annotations.Source: §3.1 · p. 6

Multi-modality Cache Model

  • Tip-Adapter’s multi-modality cache extends the visual cache with textual keys from CLIP’s classifier and identity-matrix textual values.The textual keys represent category text features produced by CLIP’s textual encoder.Source: Figure 3 · p. 7

Relations with Previous Models

  • Compared with CLIP-Adapter, Tip-Adapter retrieves few-shot knowledge directly from cached features and labels instead of learning an MLP-based adapter through SGD.CLIP-Adapter uses learnable parameters and a lower-dimensional bottleneck, whereas Tip-Adapter’s bottleneck dimension equals NK.Source: §3.2 · pp. 7–8

4 Experiments

Experiments across 11 datasets evaluate Tip-Adapter and its fine-tuned variant under few-shot, efficiency, ablation, prompt, and distribution-shift settings. Tip-Adapter improves CLIP without training, while Tip-Adapter-F delivers stronger performance with efficient fine-tuning.

Training Settings

  • Experiments cover 11 image classification datasets with 1-, 2-, 4-, 8-, and 16-shot training settings.Source: §4.1 · p. 9

ImageNet Comparison

  • Tip-Adapter consistently surpasses Zero-shot CLIP without training, while Tip-Adapter-F achieves the best performance across few-shot settings.On ImageNet, Tip-Adapter exceeds Linear-probe CLIP by +38.53% in 1-shot and +29.06% in 2-shot settings.Source: §4.2 · p. 10

Efficiency Comparison

  • Tip-Adapter improves Zero-shot CLIP by +1.70% without extra training, while Tip-Adapter-F reaches state-of-the-art accuracy using one-tenth of competing methods’ training epochs.CoOp and CLIP-Adapter require training, whereas Tip-Adapter uses the cache model for a performance-efficiency trade-off.Source: §4.2 · p. 10

Other Datasets

  • Tip-Adapter-F consistently surpasses compared methods across the other 10 datasets after fewer-epoch cache-model fine-tuning.Tip-Adapter itself surpasses CoOp trained with 1 or 2 shots on most datasets but can trail methods trained with more shots.Source: §4.3 · p. 11, Figure 5 · p. 11

Ablation Studies

  • With α=1.0, Tip-Adapter reaches 62.03% accuracy on ImageNet, balancing CLIP prior knowledge with few-shot cache knowledge.Increasing α from 0.0 to 1.0 improves accuracy; α=0.0 is equivalent to Zero-shot CLIP.Source: §4.4 · p. 12, Table 4 · p. 12
  • Constraining the cache size to 16 limits training-free gains as shots increase, whereas Tip-Adapter-F continues improving by fine-tuning cache keys.The performance boost gradually slows with more samples for training-free Tip-Adapter, but fine-tuning breaks this apparent cache-size limit.Source: §4.4 · p. 13

Prompt Design

  • Prompt ensembling outperforms a single prompt, with Tip-Adapter and Zero-shot CLIP showing larger accuracy drops under prompt variation.Tip-Adapter-F and CLIP-Adapter are less affected by changing prompt designs.Source: §4.4 · p. 13, Figure 6 · p. 13

Distribution Shift

  • Tip-Adapter shows superior robustness to distribution shift when trained on ImageNet and tested on ImageNetV2 or ImageNet-Sketch.Source: §4.5 · p. 13, Table 5 · p. 13

5 Visualization

The visualization tracks cache-key distributions before, during, and after fine-tuning. Fine-tuning makes same-category embeddings converge and different-category clusters separate more clearly.

  • Figure 7 uses t-SNE to visualize cache keys for 10 categories of 16-shot ImageNet across three fine-tuning stages.The stages are training-free Tip-Adapter, Tip-Adapter during fine-tuning, and final Tip-Adapter-F.Source: §5 · p. 14
  • Before training, the cache construction already produces discriminative category distributions.Source: §5 · p. 14
  • During fine-tuning, same-category embeddings converge while different-category clusters become more separated, supporting stronger classification capability.Source: §5 · p. 14

6 Conclusions

Tip-Adapter retrieves few-shot knowledge through a cache model and combines it with CLIP’s pre-trained knowledge without training. Tip-Adapter-F further fine-tunes cached keys, achieving state-of-the-art performance while retaining a modest training requirement.

  • Tip-Adapter constructs a non-parametric adapter from the few-shot training set and incorporates retrieved knowledge with CLIP’s pre-trained knowledge training-free.Source: §6 · p. 14
  • Tip-Adapter-F fine-tunes cached keys for a few epochs and achieves state-of-the-art performance among existing methods.Source: §6 · p. 14
  • Tip-Adapter-F still requires 20-epoch fine-tuning on ImageNet to learn the best-performing cache model.Source: §6 · p. 14

A Fine-tuning Settings

The fine-tuning experiments compare unfreezing different Tip-Adapter modules on 16-shot ImageNet. They preserve cached labels and encoders while fine-tuning cached keys for the main Tip-Adapter-F setting.

  • Tip-Adapter-F fine-tunes cache keys while freezing cache values, CLIP’s visual encoder, and textual encoder.Source: A Fine-tuning Settings · p. 15
  • The experiments train seven module-unfreezing settings for 20 epochs on 16-shot ImageNet, using smaller learning rates for CLIP encoders.Source: A Fine-tuning Settings · p. 15
  • Fine-tuning cached values reduces accuracy to 60.90%, while fine-tuning the entire cache model causes training collapse.Source: A Fine-tuning Settings · p. 15

B Performance Gain without Training

Tip-Adapter improves Zero-shot CLIP without training across 11 classification datasets under 16-shot settings. The largest reported gains occur on EuroSAT and Flowers102, where domain differences require more few-shot knowledge.

C Compared to Fully-trained Methods

Compared with conventional methods trained on full datasets, Tip-Adapter performs strongly using only 16-shot data and no parameters or training. Tip-Adapter-F improves further through efficient fine-tuning.

Loading 2207.09519v1…