Abstract
TextRefiner is a plug-and-play module designed to enhance Vision-Language Models (VLMs) like CLIP through efficient prompt tuning. Unlike existing methods that rely on external Large Language Models (LLMs) for fine-grained descriptions, TextRefiner extracts and aligns internal visual features directly from the image encoder. This approach achieves state-of-the-art accuracy across various downstream tasks while maintaining significantly higher inference speeds by avoiding the overhead of external model calls.
Introduction
Adapting massive pre-trained models like CLIP to specific tasks often involves prompt tuning—learning a small set of "soft" prompt vectors instead of retraining the entire model. However, standard prompt tuning methods, such as CoOp, typically learn a single, coarse-grained prompt for each category. This often leads to failure when distinguishing between classes with similar visual attributes, such as different dog breeds.
Recent research has attempted to address this by using LLMs to generate detailed textual descriptions. While effective, this approach is computationally expensive, requiring external model calls during inference and complex filtering to ensure descriptions match the dataset. TextRefiner proposes a more efficient alternative: leveraging the fine-grained details already captured by the image encoder's internal layers.
Methodology
TextRefiner introduces a "plug-and-play" architecture that extracts and aligns internal visual knowledge to enrich text prompts. The system consists of three primary components:
- Local Cache: Instead of an external knowledge base, TextRefiner builds a "memory" of local visual features (tokens) from the intermediate layers of the Vision Transformer (ViT) image encoder. A clustering mechanism stores representative visual attributes (e.g., "stripes" or "beaks") in a fixed-size storage module.
- Feature Aggregation: During inference, the model queries this local cache using the category's text embedding. It identifies relevant visual attributes and fuses them with the original text prompt via a residual connection.
- Feature Alignment: To bridge the modality gap between visual features and text embeddings, a simple 2-layer MLP maps the cached visual features into the text embedding space.
The training process utilizes a combination of standard classification loss, a semantic loss for text-visual alignment, and a regularization loss to prevent overfitting on small training datasets.
Experimental Evaluation
The authors evaluated TextRefiner across 11 benchmarks to test base-to-novel generalization, covering general objects (ImageNet), fine-grained categories (OxfordPets, StanfordCars), and specialized tasks (EuroSAT, UCF101). They also conducted cross-domain generalization tests using ImageNet variants like ImageNet-Sketch and ImageNet-R.
Key Results
- Performance: Integrating TextRefiner with CoOp improved average accuracy across 11 benchmarks from 71.66% to 76.94%. When combined with PromptKD, it outperformed leading LLM-based methods like LLaMP by 1.06%.
- Efficiency: TextRefiner is significantly faster than LLM-based alternatives. While LLaMP achieves approximately 1,473 FPS, TextRefiner (with PromptKD) reaches 12,793 FPS on an A800 GPU—a nearly 9x speedup.
- Robustness: The method showed consistent improvements in cross-domain scenarios, indicating that refined prompts are more resilient to style changes and adversarial images.
Conclusion
TextRefiner demonstrates that the internal layers of pre-trained image encoders contain sufficient fine-grained knowledge to refine prompts without external assistance. By replacing heavy LLM queries with efficient local cache lookups, it provides a high-performance, low-latency solution for VLM adaptation. Future work may explore adaptive cache sizes and scaling this internal refinement strategy to even larger foundation models.
Summary updated