Learning to Name Classes for Vision and Language Models

Sarah Parisot, Yongxin Yang, Steven McDonagh

Abstract

Vision-Language Models (VLMs) like CLIP have revolutionized computer vision by enabling open-vocabulary recognition through natural language. However, these models exhibit significant sensitivity to the specific text used to describe classes, a phenomenon known as "brittleness." This paper proposes a novel approach that shifts the focus from prompt engineering to the optimization of class-specific word embeddings. By learning new embeddings directly from visual data while keeping the underlying model frozen, this method significantly improves performance on rare, ambiguous, or technical categories without sacrificing the model's general-purpose capabilities.

Introduction

Modern Vision-Language Models allow users to search for images or detect objects using arbitrary text strings. Despite their versatility, these models are often limited by the quality of the text labels provided. A word like "bow" might be interpreted as a weapon, a ribbon, or a nautical term, leading to classification errors. Furthermore, highly technical labels—such as specific vehicle models—may not align well with the semantic space the model learned during pre-training.

Existing solutions typically involve "prompt tuning," which optimizes the surrounding context (e.g., "a photo of a [CLASS]"), or "linear probing," which adapts the model to a specific dataset at the cost of its open-vocabulary flexibility. This paper argues that the primary bottleneck is often the class name itself, and proposes a "Learning to Name" framework to address this.

Methodology: Textual Inversion for Classification

The researchers introduce a method inspired by textual inversion to optimize class representations. The approach consists of several key components:

  1. Frozen Foundation: The image and text encoders (e.g., CLIP or OWL-ViT) remain completely frozen. This preserves the model's broad knowledge and prevents the "forgetting" typically associated with fine-tuning.
  2. Learnable Embeddings: Instead of using the fixed word embedding for a class name, the system replaces it with a learnable vector ($E^l$).
  3. Visual-to-Text Optimization: Using a small set of training images (typically 16 per class), the model optimizes the learnable vectors so that the resulting text representation aligns as closely as possible with the visual features of the corresponding images.
  4. Modular Integration: Because the output is a standard word embedding, these learned vectors are "plug-and-play." They can be used alongside standard text embeddings, allowing a single model to handle both learned classes and zero-shot classes simultaneously.

Experimental Evaluation

The method was evaluated across three distinct domains:

  • General Classification: Tested on 11 datasets, including ImageNet, Caltech 101, and fine-grained datasets like Oxford Pets and Stanford Cars.
  • Object Detection: Evaluated on the LVIS dataset, which features a "long tail" of rare objects that are traditionally difficult for VLMs.
  • Corner Case Detection: Tested on CODA 2.0, a dataset focused on unusual road objects for autonomous driving.

Key Insights and Qualitative Analysis

Semantic Drift and Correction

The optimization process revealed how the model "interprets" visual data. In the CODA dataset, the model initially struggled with the class "tricycle." After learning a new embedding, the researchers found that the vector had moved closer to words like "rickshaw" and "cart." This suggests the model was able to find a more accurate internal description for the visual evidence than the provided label.

Linguistic Adaptation

The model also demonstrated an ability to perform "internal translation." When trained on datasets using British English labels (e.g., "postbox" or "trousers"), the learned embeddings drifted toward American English equivalents like "mailbox" and "pants." Since CLIP was trained primarily on American English internet data, the optimization process automatically corrected the dialect to match the model's pre-existing vocabulary.

Rare Class Performance

The most significant quantitative gains occurred in the "long tail." For rare classes in the LVIS dataset, the precision of the OWL-ViT model jumped from 17.7 AP to 28.5 AP. By learning a specific "name" for these rare objects, the model overcame the blurry or weak representations it had formed during general pre-training.

Results and Discussion

On average, the "Learning to Name" approach outperformed zero-shot CLIP by 10% across 11 classification datasets. It also proved more robust than popular prompt-tuning methods like CoOp, which can sometimes struggle to generalize across different datasets.

Limitations

While effective, the method requires at least a small amount of supervised data (e.g., 16 images per class), making it less suitable for purely zero-shot scenarios. In extreme low-data regimes (1-2 shots), standard prompt tuning may still hold an advantage. Additionally, while the learned embeddings are highly effective, they remain high-dimensional vectors that are not always perfectly interpretable by humans.

Conclusion

By allowing Vision-Language Models to "learn their own names" for objects, this research provides a powerful tool for adapting foundation models to specific, technical, or rare domains. This approach maintains the strengths of frozen models while providing a surgical way to improve accuracy where natural language labels fall short.

Summary updated

BibTeX
@inproceedings{parisot2023learning,
  author = {Sarah Parisot and Yongxin Yang and Steven McDonagh},
  title = {{Learning to Name Classes for Vision and Language Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure