Introduction: The Challenge of Distribution Shifts
Foundation models like CLIP exhibit remarkable zero-shot capabilities, but they frequently struggle with "distribution shifts"—the inevitable differences between their training data and the real-world data they encounter at test time.
To bridge this gap, Test-Time Prompt Tuning (TPT) learns a specific "prompt" (a set of learnable vectors) for every single image during inference. However, standard TPT treats every image as an isolated event, ignoring the valuable shared similarities among test samples. Online TPT attempts to fix this by carrying learned information sequentially from one sample to the next. Unfortunately, this introduces a fatal flaw: prompt collapse. Errors from bad predictions accumulate over time, eventually driving the model's accuracy toward zero.
DynaPrompt is introduced to secure the best of both worlds: the shared knowledge of online learning without the death spiral of error accumulation.
Methodology: The Dynamic Prompt Buffer
To prevent prompt collapse while still learning from past samples, DynaPrompt introduces a Dynamic Prompt Buffer ($\mathcal{V}$) that stores a pool of learnable prompts.
For every new test image, the system executes three main steps:
- Dynamic Prompt Selection: Instead of updating a single global prompt, DynaPrompt selects a subset of prompts from the buffer based on two metrics:
- Prediction Entropy: Measures prompt confidence. Lower entropy indicates higher confidence.
- Probability Difference: Measures how sensitive a prompt is to structural changes (augmentations) in the image. High sensitivity suggests the prompt is analyzing relevant features rather than just being blindly overconfident.
- Dynamic Prompt Appending: If no existing prompts in the buffer meet the quality threshold for the current image, the system initializes a fresh prompt from a base starting point ($\mathbf{v}_0$) and appends it to the buffer. To manage memory, it deletes the most "inactive" prompts that are rarely selected.
- Optimization: Only the selected prompts are updated using entropy minimization. Irrelevant or collapsed prompts are effectively "frozen," preventing them from being corrupted by out-of-distribution data.
Key Insights
- The "Oracle" Inspiration: The authors observed that if prompts are only updated when the model's prediction is correct (an "Oracle" setup), online tuning works exceptionally well. DynaPrompt uses Entropy and Probability Difference as a proxy for correctness to mimic this Oracle behavior.
- Diversity is Safety: Maintaining a buffer of multiple prompts allows the model to specialize different prompts for different sub-distributions within the test set.
- Sensitivity as a Filter: Overconfident, collapsed prompts often output the same prediction regardless of how much an image is augmented. By filtering for prompts that react to image changes (Probability Difference), DynaPrompt successfully weeds out broken prompts.
Key Results
The authors evaluated DynaPrompt across 14 diverse benchmarks, including Domain Generalization (e.g., ImageNet-A, ImageNet-R) and Cross-Dataset Transfer (e.g., EuroSAT, UCF101).
- Superior Accuracy: DynaPrompt consistently outperformed standard TPT. On the notoriously difficult ImageNet-A dataset, it achieved 56.17% accuracy, compared to TPT's 54.77%.
- Fixing the Collapse: Standard Online TPT's accuracy plummeted to a mere 6.96% on ImageNet-A due to error accumulation. In stark contrast, DynaPrompt remained stable and improved over time, closely mirroring the ideal Oracle performance.
- Plug-and-Play Compatibility: The method is orthogonal to existing techniques. When combined with methods like CoOp or MaPLe, DynaPrompt provided an additional performance boost (e.g., raising CoOp + TPT from 62.84% to 64.31% on average).
Limitations and Future Work
While highly effective, DynaPrompt introduces some computational overhead. The selection process is fast (~0.004 seconds per sample), but optimizing multiple prompts in the buffer increases the total processing time per image (roughly 0.39s vs. TPT's 0.2s). Additionally, like all online methods, results can fluctuate slightly depending on the order of incoming test images, though DynaPrompt is significantly more stable than its predecessors.
Future work may explore more sophisticated buffer deletion policies and extend this dynamic logic to multimodal prompts, tuning both vision and language branches simultaneously.
Summary updated