Manipulating the Label Space for In-Context Classification

Haokun Chen, Xu Yang, Yuhang Huang, Zihan Wu, Jing Wang, Xin GengarXiv 2023

Abstract

After pre-training by generating the next word conditional on previous words, the Language Model (LM) acquires the ability of In-Context Learning (ICL) that can learn a new task conditional on the context of the given in-context examples (ICEs). Similarly, visually-conditioned Language Modelling is also used to train Vision-Language Models (VLMs) with ICL ability. However, such VLMs typically exhibit weaker classification abilities compared to contrastive learning-based models like CLIP, since the Language Modelling objective does not directly contrast whether an object is paired with a text. To improve the ICL of classification, using more ICEs to provide more knowledge is a straightforward way. However, this may largely increase the selection time, and more importantly, the inclusion of additional in-context images tends to extend the length of the in-context sequence beyond the processing capacity of a VLM. To alleviate these limitations, we propose to manipulate the label space of each ICE to increase its knowledge density, allowing for fewer ICEs to convey as much information as a larger set would. Specifically, we propose two strategies which are Label Distribution Enhancement and Visual Descriptions Enhancement to improve In-context classification performance on diverse datasets, including the classic ImageNet and more fine-grained datasets like CUB-200. Specifically, using our approach on ImageNet, we increase accuracy from 74.70% in a 4-shot setting to 76.21% with just 2 shots, surpassing CLIP by 0.67%. On CUB-200, our method raises 1-shot accuracy from 48.86% to 69.05%, 12.15% higher than CLIP.

Introduction

Vision-Language Models (VLMs) like Flamingo have demonstrated a remarkable capacity for In-Context Learning (ICL), enabling them to adapt to new tasks through a few provided examples in a prompt. However, in the domain of image classification, these models often underperform compared to contrastive models like CLIP. The standard approach to bolster ICL performance—increasing the number of in-context examples (ICEs)—is limited by the model's context window and the computational cost of processing multiple images.

Furthermore, simple category labels (e.g., "sparrow") offer low "knowledge density." This paper addresses these challenges by manipulating the label space of ICEs to pack more semantic and visual information into fewer examples, effectively bridging the performance gap between generative VLMs and contrastive models.

Proposed Methodology

The core innovation lies in increasing the information content of each example through two primary strategies: Label Distribution Enhancement (LDE) and Visual Descriptions Enhancement (VDE).

Comparison of standard ICL with LDE and VDE strategies for manipulating the label space.

1. Label Distribution Enhancement (LDE)

Instead of providing a single "hard" label, LDE presents a probability distribution. By using CLIP to calculate similarities between the image and a label corpus, the prompt can describe class relationships. For example, a prompt might state: "Persian Cat, but may have a 51% probability of being a Japanese Chin." This allows the VLM to understand the boundaries and potential confusions between similar categories, providing a "safety net" for the model's reasoning.

2. Visual Descriptions Enhancement (VDE)

VDE leverages the VLM itself to generate detailed visual descriptors for each class. Rather than just a name, the prompt includes grounded visual cues such as: "Persian Cat: has large orange eyes, dense grey fur, and a round body." This explicitly guides the model to look for specific features, which is particularly beneficial for fine-grained classification where subtle details distinguish species or models.

Detailed technical pipeline for implementing LDE and VDE within a VLM framework.

Experimental Results

The proposed methods were evaluated across several benchmarks, including ImageNet, CUB-200 (birds), Stanford Dogs, and Stanford Cars. The results demonstrate that "quality over quantity" in labeling is a superior strategy for ICL:

  • ImageNet: In a 2-shot setting, the method achieved 76.21% accuracy, outperforming standard 4-shot ICL and surpassing CLIP by 0.67%.
  • CUB-200: The most significant gains were observed here, with 1-shot accuracy jumping from 48.86% to 69.05%—a 20% improvement over the baseline and 12.15% higher than CLIP.
  • Stanford Cars: 1-shot accuracy improved by over 20% compared to standard ICL.
  • Generalization: The VDE strategy proved robust on a custom "New Class Benchmark" featuring car models released between 2022 and 2024, showing that the model can identify objects it did not encounter during pre-training by relying on visual descriptions.

Conclusion

Manipulating the label space through LDE and VDE significantly enhances the classification capabilities of VLMs while maintaining a small context footprint. By increasing the knowledge density of in-context examples, this approach allows models to achieve state-of-the-art performance with fewer shots, effectively overcoming the limitations of standard generative objectives in classification tasks.

Summary updated

BibTeX
@misc{chen2023manipulating,
  author = {Haokun Chen and Xu Yang and Yuhang Huang and Zihan Wu and Jing Wang and Xin Geng},
  title = {{Manipulating the Label Space for In-Context Classification}},
  year = {2023},
  eprint = {2312.00351},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.00351},
}
Figure