Introduction
Anomaly detection (AD) is critical for identifying deviations from normal patterns in domains such as cybersecurity, fraud detection, and healthcare. While deep learning has seen significant success in image and text AD, tabular data remains challenging. Most existing methods treat inputs in isolation, focusing either on feature-feature dependencies (internal relationships within a row) or sample-sample dependencies (how a row compares to the population). This paper introduces NPT-AD, a method that leverages Non-Parametric Transformers to model both types of dependencies simultaneously.
Methods: The NPT-AD Architecture
NPT-AD adapts the Non-Parametric Transformer (NPT) for unsupervised reconstruction. Unlike standard Transformers, NPT-AD employs two alternating attention mechanisms:
- Attention Between Attributes (ABA): Captures relationships between different features within a single sample.
- Attention Between Datapoints (ABD): Captures relationships across different samples in the dataset.
The model is trained using a masked feature reconstruction framework. During training, features of normal samples are masked, and the model learns to predict them using the remaining features and context from other samples.
During inference, the model uses the entire training set as a reference to reconstruct features of a new sample. A high reconstruction error indicates that the sample is an anomaly.
Experimental Evaluation
The authors evaluated NPT-AD on a benchmark of 31 tabular datasets, including 28 from the ODDS collection and three high-dimensional real-world datasets (fraud, campaign, and backdoor). NPT-AD was compared against 17 other methods, ranging from classical algorithms like Isolation Forest to modern deep learning approaches like GOAD and NeuTraL-AD.
Key Results
NPT-AD established a new state-of-the-art (SOTA) for tabular anomaly detection. It achieved the highest average F1-score of 68.8% and the best average ranking among all tested models.
The results demonstrate that modeling both feature and sample dependencies provides a significant advantage. Ablation studies confirmed that removing either the ABA or ABD layers leads to a substantial performance drop.
Robustness and Limitations
NPT-AD exhibits remarkable robustness to training set contamination. It maintains high performance even when up to 5% of the training data consists of hidden anomalies. However, the non-parametric nature of the model introduces computational overhead. As the number of samples and features grows, inference time and memory usage increase, suggesting that future work should focus on more efficient retrieval mechanisms for large-scale applications.
Conclusion
By moving beyond individual input processing, NPT-AD provides a powerful framework for tabular anomaly detection. Its ability to integrate feature-level and sample-level context allows it to consistently outperform existing methods across a wide variety of datasets.
Summary updated