NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hierarchical Vector Quantized Transformer for Multi-class Unsupervised Anomaly Detection

Ruiying Lu, YuJie Wu, Long Tian, Dongsheng Wang, Bo Chen, Xiyang Liu, Ruimin Hu

Abstract

Unsupervised Anomaly Detection (UAD) typically relies on learning normal data distributions to identify outliers. However, unified models covering multiple classes often suffer from the "identical shortcut" problem, where the model learns to reconstruct anomalies as effectively as normal samples. We present HVQ-Trans, a framework that utilizes hierarchical vector quantization to map features into discrete "iconic prototypes." By restricting the reconstruction vocabulary to known normal patterns, HVQ-Trans effectively filters out anomalies. Our approach achieves state-of-the-art performance on MVTec-AD and VisA benchmarks, demonstrating the power of discrete bottlenecks in multi-class anomaly detection.

Introduction: The "Identical Shortcut" Problem

Traditional UAD methods often employ a "one-for-one" strategy, training a dedicated model for each object category. While effective, this approach lacks scalability. Modern research has shifted toward "one-for-all" unified models. However, these models frequently encounter the identical shortcut: because the model must be expressive enough to represent diverse normal patterns, it often learns a simple identity mapping. Consequently, it reconstructs anomalous regions with high fidelity, making them indistinguishable from normal data based on reconstruction error.

Conceptual overview of iconic normal prototypes and how they force anomalous regions to be reconstructed as normal equivalents.

The HVQ-Trans Framework

To address the shortcut problem, HVQ-Trans introduces a discrete information bottleneck. Instead of continuous latent representations, the model utilizes a set of learned "iconic prototypes" that represent the vocabulary of normal features.

Hierarchical Vector Quantization (VQ)

The core innovation is the use of hierarchical VQ layers. By mapping image features to discrete codebook entries, the model is physically constrained. Since the codebook only contains normal prototypes, any anomalous input is forced to be reconstructed using the nearest normal building blocks. This "flips" abnormal regions into normal ones, creating a significant reconstruction error that serves as a clear anomaly signal.

Architectural Components

The framework consists of several key modules:

  1. VQ-based Transformer Decoder: Employs cross-attention to integrate image features with discrete prototypes, biasing the output toward the learned normal distribution.
  2. Switching Mechanism: A class-aware router adaptively selects the appropriate codebook and expert reconstruction network for different object classes, managing the complexity of multi-class data.
  3. Prototype-oriented Optimal Transport (POT): Aligns prototypes with normal feature distributions during training and provides a robust global anomaly score at inference.
The overall HVQ-Trans architecture, including the hierarchical VQ layers, switching mechanism, and transformer decoder.

Experimental Results

HVQ-Trans was evaluated on the MVTec-AD and VisA datasets, setting new benchmarks for unified anomaly detection.

  • MVTec-AD: Achieved a detection AUROC of 98.0%, outperforming previous state-of-the-art models like UniAD (96.5%) and PatchCore (96.4%).
  • VisA: Reached 93.2% AUROC, a significant improvement over existing unified approaches.
  • Ablation Study: Removing the VQ module led to a performance drop of approximately 26%, confirming that the discrete bottleneck is essential for preventing the identical shortcut.

Conclusion

HVQ-Trans demonstrates that discreteness is a powerful tool for anomaly detection. By forcing a model to "speak" only in the vocabulary of normal prototypes, we can effectively prevent the learning of identity shortcuts. While the current model utilizes category labels for its switching mechanism during training, future work could explore fully unsupervised category discovery to further enhance scalability and autonomy in industrial inspection.

Summary updated

BibTeX
@inproceedings{lu2023hierarchical,
  author = {Ruiying Lu and YuJie Wu and Long Tian and Dongsheng Wang and Bo Chen and Xiyang Liu and Ruimin Hu},
  title = {{Hierarchical Vector Quantized Transformer for Multi-class Unsupervised Anomaly Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=clJTNssgn6},
}
Figure