IRGen: Generative Modeling for Image Retrieval

Yidan Zhang, Ting Zhang, Dong Chen, Yujing Wang, Qi Chen, Xing Xie, Hao Sun, Weiwei Deng, Qi Zhang, Fan Yang, Mao Yang, Qingmin Liao, Jingdong Wang, Baining Guo

Introduction

Traditional image retrieval systems are typically architected as a two-stage process: feature representation learning followed by Approximate Nearest Neighbor (ANN) search. In the first stage, a vision model extracts high-dimensional vectors from images. In the second, these vectors are indexed and searched using distance metrics like Euclidean distance or cosine similarity. This disjointed pipeline often requires significant manual tuning to align the representation space with the indexing mechanism.

IRGen proposes a paradigm shift by reframing image retrieval as a generative modeling task. Instead of calculating distances between vectors, the model is trained to "generate" the discrete identifiers of an image's nearest neighbors. This approach unifies feature learning and search into a single, end-to-end differentiable framework, leveraging the power of sequence-to-sequence Transformers.

The IRGen Framework

Semantic Image Tokenization

A core challenge in generative retrieval is converting images into a sequence of discrete tokens. While existing image tokenizers like VQ-VAE focus on pixel-level reconstruction, they often capture irrelevant background noise and produce sequences too long for efficient retrieval.

IRGen introduces a Semantic Image Tokenizer. It utilizes the global "class token" from a Vision Transformer (ViT) and applies Residual Quantization (RQ) to map this feature into a short, fixed-length sequence of discrete codes (e.g., 4 tokens). Crucially, this tokenizer is optimized using a classification loss rather than a reconstruction loss. This ensures that the generated tokens represent high-level semantic information—the "identity" of the object—rather than raw pixel data.

Generative Retrieval and Inference

The model architecture consists of a standard Transformer encoder-decoder. The encoder processes the query image, while the decoder predicts the identifier tokens of the target image in an autoregressive manner.

The IRGen architecture overview, showing the semantic tokenizer, encoder-decoder, and beam search process.

During inference, the model employs Beam Search to find the most probable identifier sequences. To ensure the model only generates identifiers corresponding to actual images in the database, the search is constrained by a Prefix Tree (Trie). This constraint significantly boosts both the accuracy and the efficiency of the retrieval process.

Experimental Evaluation

Benchmarks and Datasets

The performance of IRGen was evaluated on several standard benchmarks, including In-shop Clothes, CUB200 (birds), and Cars196. To test scalability, the authors also conducted experiments on million-scale datasets such as ImageNet (1.28M images) and Places365 (1.8M images).

Comparative Results

IRGen demonstrates superior precision across all tested benchmarks. Notably, it outperforms traditional linear scan search, which is often considered the theoretical upper bound for distance-based retrieval accuracy.

Performance comparison of IRGen against state-of-the-art baselines on standard benchmarks.

As shown in the results table, IRGen achieved a 20.2% increase in Precision@10 on the In-shop Clothes dataset compared to the strongest baseline (FT-CLIP). Furthermore, the model maintains high Mean Average Precision (MAP) on million-scale datasets, proving its robustness at scale.

Discussion and Conclusion

By treating retrieval as a "naming" task, IRGen bypasses the need for complex ANN indexing and heavy reranking stages. The model is highly efficient, requiring only 4 bytes of storage per image in the database—a massive reduction from the ~3KB required by standard vector-based methods.

While IRGen shows great promise, scaling to billions of images remains a challenge for future research. The computational cost of training large autoregressive models and the need for adaptive structures to handle dynamic dataset updates are also key areas for further exploration. Nonetheless, IRGen represents a significant step toward unifying computer vision and information retrieval through generative modeling.

Summary updated

BibTeX
@inproceedings{zhang2024irgen,
  author = {Yidan Zhang and Ting Zhang and Dong Chen and Yujing Wang and Qi Chen and Xing Xie and Hao Sun and Weiwei Deng and Qi Zhang and Fan Yang and Mao Yang and Qingmin Liao and Jingdong Wang and Baining Guo},
  title = {{IRGen: Generative Modeling for Image Retrieval}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72633-0\_2},
}
Figure