A Flexible Plug-and-Play Module for Generating Variable-Length

Liyang He, Yuren Zhang, Rui Li, Zhenya Huang, Runze Wu, Enhong ChenarXiv 2024 · DOI

Introduction

Large-scale image retrieval relies on hashing to compress high-dimensional features into compact binary strings. This process enables fast, memory-efficient searching across massive datasets. However, a significant challenge remains: the trade-off between efficiency and effectiveness. Shorter codes offer speed and low storage costs but sacrifice accuracy, while longer codes improve precision at the cost of higher resource consumption. Traditionally, finding the optimal bit length requires training multiple independent models, a computationally expensive process that fails to exploit the shared information between different code lengths. Furthermore, some models suffer from a "dimensionality curse," where performance unexpectedly drops as code length increases.

Comparison of traditional vs. nested hashing architectures and the efficiency-effectiveness trade-off.

The Nested Hash Layer (NHL)

To address these inefficiencies, the authors propose the Nested Hash Layer (NHL), a plug-and-play module designed to replace the standard final fully connected layer in hashing networks. The NHL enables a single model to generate multiple hash code lengths simultaneously through three core innovations:

  1. Nested Weight Structure: Instead of maintaining separate weights for each bit length, the NHL nests them. For example, the weights for a 16-bit code are a subset (the first $n$ columns) of the weights for a 32-bit code. This allows for multi-length generation in a single forward pass.
  2. Dominance-Aware Dynamic Weighting (DADW): Training multiple lengths concurrently can lead to gradient conflicts. Since shorter codes are subsets of longer ones, they are inherently more "significant." DADW dynamically balances the loss functions, ensuring that the optimization of longer codes does not degrade the quality of the foundational shorter codes.
  3. Long-short Cascade Self-distillation: This technique uses longer hash codes as "teachers" for shorter ones. By transferring relational knowledge from the high-dimensional space to the low-dimensional space, the model ensures that even the shortest codes capture complex image relationships.
Technical components of the NHL: basic structure, dynamic weighting (DADW), and self-distillation.

Experimental Results

The NHL was evaluated on standard benchmarks including CIFAR-10, ImageNet100, and MSCOCO, using various backbones like ResNet, MobileNetV2, and Vision Transformers (ViT). Key findings include:

  • Massive Speedup: By replacing multiple training runs with a single session, the NHL achieves a 5x to 8x improvement in total training speed.
  • Enhanced Accuracy: The module consistently outperformed traditional methods, providing an average 3.4% improvement in Mean Average Precision (mAP) across all models and datasets.
  • Plug-and-Play Flexibility: The module proved highly adaptable, improving performance regardless of whether a classic CNN or a modern Transformer-based architecture was used.
  • Solving the Dimensionality Curse: By forcing the model to learn short and long codes together, the nested constraint acts as a form of regularization that keeps high-dimensional mappings stable, preventing the performance drop-off often seen in very long hash codes.

Conclusion

The Nested Hash Layer offers a highly efficient and effective solution for modern retrieval systems. By treating shorter codes as the foundation for longer ones and employing intelligent gradient weighting, it provides a significant boost to both training efficiency and retrieval accuracy. While the current work focuses on symmetric hashing, future research may extend this nested approach to asymmetric setups or explore coarse-to-fine search strategies using variable-length prefixes.

Summary updated

BibTeX
@misc{he2024flexible,
  author = {Liyang He and Yuren Zhang and Rui Li and Zhenya Huang and Runze Wu and Enhong Chen},
  title = {{A Flexible Plug-and-Play Module for Generating Variable-Length}},
  year = {2024},
  eprint = {2412.08922},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.08922},
}
Figure