Foundation models and Transformers for anomaly detection: A survey

Mouïn Ben Ammar, Arturo Mendoza, Nacim Belkhir, Antoine Manzanera, Gianni Franchi

Abstract

Visual Anomaly Detection (VAD) is undergoing a paradigm shift from local, convolution-based architectures to global, attention-driven Transformers and Foundation Models. This survey explores how these advancements address traditional limitations like the "identity mapping trap" and enable high-performance detection in zero-shot or data-scarce scenarios.

Introduction

Visual Anomaly Detection (VAD) involves identifying and localizing deviations from "normal" patterns in images or video, a task vital for industrial manufacturing, medical diagnostics, and security surveillance. Historically, Convolutional Neural Networks (CNNs) served as the primary tool for VAD. However, CNNs are inherently limited by their local receptive fields, making them effective for local defects (e.g., surface scratches) but poor at detecting logical or global anomalies where the spatial arrangement of otherwise normal components is incorrect.

Furthermore, traditional VAD methods typically require extensive "normal" datasets for training, which are often difficult to obtain in specialized domains. The emergence of Transformers and Foundation Models (e.g., CLIP, SAM) offers a solution through global context modeling and zero-shot transfer learning capabilities.

Transformer-Based Methodologies

The survey categorizes Transformer-based VAD into three primary families:

  1. Reconstruction and Prediction-Based: These models learn to reconstruct "normal" data. Anomalies are flagged based on high reconstruction error. Transformers utilize query embeddings to mitigate the "identity mapping trap," where a model learns to simply copy input pixels without structural understanding.
  2. Feature-Based: These methods leverage high-level features from pre-trained models. Common techniques include Knowledge Distillation—where a student model mimics a teacher's features on normal data—and Memory Banks that store libraries of normal feature representations.
  3. Zero- and Few-Shot (Foundation Models): Utilizing models like CLIP (Vision-Language) or SAM (Segment Anything), researchers can detect anomalies via text prompts or general segmentation masks, often requiring no domain-specific training data.
Overview of the Vision Transformer (ViT) architecture, illustrating the process of patch embedding and the internal structure of the Transformer Encoder.

Key Insights: Global Context and Foundation Models

A defining advantage of Transformers is the use of self-attention, which provides a global receptive field. Unlike CNNs, which process images through local filters, Transformers can relate distant image patches simultaneously.

Mean attention distance as a function of network depth for ViT-L/16, demonstrating how attention heads capture increasingly global information in deeper layers.

Key technical insights include:

  • Overcoming Identity Mapping: By using bottlenecked query embeddings or Masked Autoencoding (MAE), Transformers are forced to learn global structural relationships rather than local textures, preventing them from perfectly reconstructing anomalous regions.
  • Anomaly Detection via Description: Foundation models like CLIP enable a shift toward "Anomaly Detection via Description." By aligning visual features with textual concepts, defects can be identified by querying the model for specific textual descriptions (e.g., "broken component").
  • Prompt Tuning: Efficiency is gained by tuning small prompts rather than retraining entire large-scale models, facilitating the adaptation of Foundation Models to specific industrial tasks with minimal data.

Benchmarks and Performance

The survey highlights several standard benchmarks across various domains:

  • Industrial: MVTec AD, VisA.
  • Video/Surveillance: ShanghaiTech, Avenue, UCSD Ped2.
  • Medical: Brain MRI and X-ray datasets.
  • Multimodal: Recent benchmarks like the "LLMs benchmark for industrial anomaly detection" evaluate how large multimodal models handle complex industrial scenes.

Current state-of-the-art (SOTA) trends indicate that hybrid architectures—combining CNN backbones for local feature extraction with Transformer encoders for global context—currently provide the best balance of precision and robustness. Additionally, Foundation Models are achieving competitive results in zero-shot settings that previously required significant training data.

Limitations and Future Directions

Despite their power, Transformers and Foundation Models face several challenges:

  • Computational Demand: High resource requirements make deployment on edge devices (e.g., assembly line cameras) difficult.
  • Interpretability: Explaining the reasoning behind a Foundation Model's decision, particularly in complex text-image alignments, remains an open research problem.
  • Data Bias: Models pre-trained on web-scale data may lack the specific industrial vocabulary or suffer from biases.

Future research is expected to focus on improving uncertainty estimation—allowing models to signal low confidence rather than producing false positives—and developing lightweight, "edge-ready" Transformer variants.

Summary updated

BibTeX
@article{ammar2025foundation,
  author = {Mouïn Ben Ammar and Arturo Mendoza and Nacim Belkhir and Antoine Manzanera and Gianni Franchi},
  title = {{Foundation models and Transformers for anomaly detection: A survey}},
  journal = {Information Fusion},
  year = {2025},
}
Figure