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

VQ-Flow: Taming Normalizing Flows for Multi-Class Anomaly Detection via Hierarchical Vector Quantization

Yixuan Zhou, Xing Xu, Zhe Sun, Jingkuan Song, Andrzej Cichocki, Heng Tao Shen

TL;DR

Normalizing flows excel at single-class anomaly detection but struggle when normal data contains a mix of multiple unlabeled classes. VQ-Flow solves this by integrating hierarchical vector quantization to automatically separate distinct data concepts and model them using a mixed Gaussian distribution. This unified approach achieves state-of-the-art performance on multi-class anomaly detection benchmarks while maintaining real-time inference speeds.

What Problem Does This Paper Address?

Unsupervised Anomaly Detection (UAD) is typically framed as a single-class problem (SCAD), where a model trains exclusively on homogeneous normal data (e.g., inspecting only one type of product on a factory line). However, real-world applications often demand a Multi-Class Anomaly Detection (MCAD) setup, where a single unified model must learn from a blend of distinct normal categories without explicit class labels.

When traditional SCAD methods encounter mixed-class data, their performance degrades because they get confused by the overlapping and entangled patterns. Previous MCAD approaches often oversimplify this complex, multi-modal data distribution by mapping it to a single, simplistic Gaussian distribution. This causes the model to lose the fine-grained nuances of individual classes, leading to suboptimal anomaly detection.

Simplifying multi-class distributions vs VQ-Flow's mixed Gaussian approach

Methods

The authors introduce VQ-Flow, a novel framework that equips normalizing flows with unsupervised concept distinction by integrating Hierarchical Vector Quantization (VQ).

The architecture consists of three main pillars:

  1. Conceptual Prototype Codebook (CPC): The model passes high-level semantic features through a vector quantization layer to learn discrete "conceptual prototypes." These prototypes act as unsupervised pseudo-class labels to separate different categories.
  2. Concept-Specific Pattern Codebook (CSPC): To capture fine-grained structural details, VQ-Flow uses residual quantization. It quantizes the difference (residual) between detailed feature maps and the high-level CPC prototypes. Positional embeddings (PE) are concatenated here to provide spatial awareness.
  3. Concept-Aware Conditional Distribution Modeling: Standard normalizing flows map data to a simple, standard Gaussian distribution. VQ-Flow replaces this with a Mixed Gaussian Distribution reparameterized on the discovered conceptual prototypes, allowing the flow model to faithfully represent complex, multi-class data.
Overview of the VQ-Flow architecture

Datasets

The authors evaluated VQ-Flow on three challenging benchmarks:

  • MVTec AD: An industrial dataset containing 15 categories (10 objects, 5 textures) with normal training images and various anomalous testing images.
  • VisA: A newer industrial dataset featuring 12 categories of products with highly complex spatial layouts.
  • CIFAR-10: Used to evaluate semantic anomaly detection, where a subset of 5 classes is treated as normal and the remaining 5 are treated as anomalies.

Key Insights and Ideas

  • Normalizing Flows are Viable for MCAD: While previously overlooked for multi-class settings due to distribution entanglement, normalizing flows can be successfully "tamed" if paired with a discrete quantization mechanism to separate underlying concepts.
  • The Power of Residual Quantization: Naive quantization lacks semantic perception. By quantizing the residual between detailed features and semantic prototypes, the CSPC effectively isolates class-specific structural patterns (see Figure 4).
  • Eliminating the Memory Bank Bottleneck: Recent state-of-the-art unified methods (like Uniformaly) rely on large memory banks, requiring heavy distance computations during inference that slow them down to ~1 FPS. VQ-Flow bypasses this by using efficient codebook lookups, making it highly practical for real-time industrial deployment.

Key Results

VQ-Flow sets a new standard for unified multi-class anomaly detection across multiple metrics:

  • MVTec AD (Unified Setting): Achieves an outstanding 99.5% Detection AUROC and 98.3% Localization AUROC, outperforming all previous unified methods (such as UniAD and HVQ-Trans).
  • VisA (Unified Setting): Reaches 95.9% Detection / 98.9% Localization AUROC, notably outperforming even the baseline flow model trained in a single-class setting.
  • CIFAR-10: Delivers a mean AUROC of 88.6%, demonstrating strong capability in semantic anomaly detection.
  • Inference Speed: Depending on the backbone network, VQ-Flow runs comfortably at real-time speeds—achieving 33 FPS with a robust ConvNeXt backbone and up to 58 FPS with a lighter ResNet-18 architecture.

Limitations and Future Work

The paper does not include a dedicated section on limitations. However, because VQ-Flow relies on a pre-trained feature extractor (e.g., ConvNeXt or ResNet) to feed both its semantic and detailed feature pipelines, its performance is inherently bound to the quality and domain-relevance of these underlying embeddings. Future work could explore joint end-to-end training of the feature extractor alongside the codebooks and flow models.

Summary updated

BibTeX
@article{zhou2025vq,
  author = {Yixuan Zhou and Xing Xu and Zhe Sun and Jingkuan Song and Andrzej Cichocki and Heng Tao Shen},
  title = {{VQ-Flow: Taming Normalizing Flows for Multi-Class Anomaly Detection via Hierarchical Vector Quantization}},
  journal = {IEEE Trans. Multimedia},
  year = {2025},
  doi = {10.1109/tmm.2025.3590900},
}
Figure