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

Learning Unified Reference Representation for Unsupervised Multi-class Anomaly Detection

Liren He, Zhengkai Jiang, Jinlong Peng, Wenbing Zhu, Liang Liu, Qiangang Du, Xiaobin Hu, Mingmin Chi, Yabiao Wang, Chengjie Wang

Introduction

In industrial quality control, anomaly detection (AD) is a critical task focused on identifying defects such as scratches, cracks, or missing components. Traditionally, AD models have been developed using a "single-class" paradigm, where a dedicated model is trained for each specific object category (e.g., one for bottles, another for cables). While effective, this approach is computationally expensive and difficult to scale in diverse manufacturing environments.

Recent research has shifted toward unified multi-class anomaly detection, aiming to train a single model capable of detecting anomalies across dozens of different categories simultaneously. However, the dominant approach—reconstruction-based learning—faces a significant hurdle known as the "learning shortcut." This paper introduces RLR (Reconstruct features from a Learnable Reference representation), a novel framework designed to overcome these shortcuts and set a new benchmark for the field.

The Challenge: The Learning Shortcut Loophole

Reconstruction-based models operate on a simple premise: they learn to reconstruct normal images. During testing, if the model encounters an anomaly, it should fail to reconstruct it, resulting in a high reconstruction error (the anomaly score).

In practice, these models often "cheat" by learning identity mappings—essentially copying pixels or features from the input to the output. When a defect like a crack appears, a model that has learned a shortcut will reconstruct the crack perfectly instead of replacing it with a normal texture. This leads to a low anomaly score and a failure to detect the defect. RLR addresses this by fundamentally breaking the direct link between input features and the reconstruction process.

Methodology: The RLR Framework

RLR prevents shortcuts by forcing the model to "re-imagine" the input using a separate, learnable memory of normal patterns rather than the input features themselves.

1. Learnable Reference Representation

Instead of reconstructing input features directly, RLR utilizes a set of randomly initialized, learnable "reference tokens." These tokens are trained to act as a dictionary of the "essence" of normalcy across all object classes. By bottlenecking the reconstruction through these tokens, the model is prevented from simply passing through anomalous input data.

2. Local Cross Attention (LCA)

To ensure the reconstruction respects the spatial structure of the image, the authors developed the Local Cross Attention module. This module treats input features as Queries and the learnable reference tokens as Keys and Values. A "local aware mask" is applied to force the model to focus only on nearby reference tokens, capturing the fine-grained textures essential for industrial inspection.

3. Masked Learnable Key Attention (MLKA)

As a secondary path, MLKA uses the learnable reference as the Key to compute attention but applies a "neighbor mask." This mask makes tokens invisible to themselves and their immediate neighbors, further discouraging the model from relying on local identity mappings and forcing it to generalize from the broader learned reference.

4. Shortcut-Free Architecture

A crucial architectural decision in RLR is the removal of residual connections (skip connections) within the attention modules. In standard Transformers, residual connections provide a direct path for input features to reach the output. By removing them, RLR forces the network to rely entirely on the learnable reference to generate the reconstruction.

Experimental Results

RLR was evaluated on two of the most rigorous benchmarks in anomaly detection: MVTec-AD (15 categories) and VisA (12 categories, including complex multi-instance objects).

Performance Benchmarks

RLR achieved state-of-the-art (SOTA) results in the unified multi-class setting, significantly outperforming previous models like UniAD and OmniAL:

  • MVTec-AD: Achieved 98.6% Image-AUROC and 98.5% Pixel-AUROC. This represents a substantial improvement over UniAD (96.5%) and OmniAL (97.2%).
  • VisA: Achieved 95.9% Image-AUROC and 99.2% Pixel-AUROC, notably outperforming UniAD’s 91.5% Image-AUROC.

Qualitative analysis confirms that RLR successfully "fixes" anomalous regions in its reconstructions. While previous models often struggle to remove defects from the reconstructed image, RLR replaces defective areas with clean, normal-looking features, resulting in highly accurate and clear anomaly maps.

Discussion and Limitations

While RLR sets a new standard for unified AD, the authors identified specific areas for improvement:

  • Background Sensitivity: In certain categories, such as the "Toothbrush" in MVTec-AD, the model occasionally flags background noise as anomalous.
  • Subtle Variance: The model struggles with datasets like "Capsules" in VisA, where natural color variations are difficult to distinguish from actual defects.
  • Scaling Efficiency: While the single reference approach is efficient, the authors noted that increasing the number of learnable references to capture more diversity introduces computational overhead without guaranteed performance gains.

Conclusion

RLR demonstrates that by breaking the "learning shortcut" through a learnable reference representation and a shortcut-free architecture, a single model can effectively master anomaly detection across a wide variety of object classes. This work paves the way for more scalable and robust automated inspection systems in industrial settings.

Summary updated

BibTeX
@inproceedings{he2024learning,
  author = {Liren He and Zhengkai Jiang and Jinlong Peng and Wenbing Zhu and Liang Liu and Qiangang Du and Xiaobin Hu and Mingmin Chi and Yabiao Wang and Chengjie Wang},
  title = {{Learning Unified Reference Representation for Unsupervised Multi-class Anomaly Detection}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72855-6\_13},
}
Figure