Skip to content
Dario Loi
Search
Menu

A Metacognitive Perspective on Anomaly Detection with Vision Foundation Models

  • Matteo Galiazzo1
  • Gabriele Onorato1,*
  • Dario Loi1
  • Nathaniel D. Bastian2
  • Francesco Restuccia1
  • 1 Northeastern University
  • 2 Pathfinder Applied Research, LLC

* Corresponding author

AAAI 2026 Fall Symposium on Artificial Metacognition (METACOG-26)

A pipeline from left to right. A frozen DINOv3 encoder, labeled object level, feeds patch features along an arrow labeled monitoring into a gray box labeled meta level, which contains two scorers, nearest neighbor and Mahalanobis, and the anomaly map they produce. An arrow labeled control, under an EVT threshold curve, leads to a binary defect mask labeled decision.
Figure 1.The metacognitive reading. Anomaly detection is a two-level system, with a frozen encoder as the object level and a scorer as the meta level that monitors it. A threshold on the meta level's output gives the decision.

On this page

In short A simpler Gaussian scorer finds defective regions more accurately than nearest-neighbor search, yet segments them worse at its default threshold. A threshold from extreme value theory recovers the loss without defective examples, so scoring and thresholding should be evaluated separately.

036912scoremean + 3 sdtail 0.135%
0.50
Flagged at mean + 3 sd
1.54%
Flagged at tail quantile
0.135%
Where the threshold sits. As the tail of the normal scores grows heavier, a threshold at the mean plus three standard deviations flags more normal pixels, whereas one fitted on the tail keeps its rate.

Abstract

Anomaly Detection (AD) in images identifies defective regions by scoring against a model of normality learned from defect-free data. Current state of the art methods encode images via a frozen Vision Foundation Model (VFM) backbone and score them by their Nearest-Neighbor (NN) distance to a memory bank of normal samples. Recently, due to the parallel evolution of VFM encoders and scoring mechanism, the need to disentangle their individual contributions has emerged, in order to guarantee the deployment of the best performing model in specific industrial production environments. In our work, we analyze AD within a metacognitive perspective, we freeze the backbone and swap the scorer, replacing NN distance with a Mahalanobis score over a Gaussian distribution. By doing that, we can evaluate two different metacognitive functions of the scoring mechanisms: monitoring how far an observation is from the learned model of normality via a threshold-free metric, and deciding when the difference justifies an action according to a threshold. We show that these two metacognitive functions can dissociate. We further notice that replacing a NN memory bank with a simpler Mahalanobis model improves pixel-level monitoring (+8.00 AU-PRO0.05_{0.05} on MVTec AD 2) while degrading the segmentation performance after the thresholding step (−13.46 F1)(-13.46\ F_1). Lastly, we show that a threshold derived by Extreme Value Theory (EVT) recovers that loss without using anomalous data: the decision stops contradicting the monitoring signal, the F1F_1 difference between the two scorers decreases from 13.46 to 0.61 points on MVTec AD 2, with consistent gains on MVTec AD and VisA.


The paper applies the two-level model of metacognition (Nelson and Narens, 1990) to structural anomaly detection. A frozen Vision Foundation Model is the object level. It produces patch features only. The scorer is the meta level and stores a model of what normal features look like. The threshold that turns its anomaly map into a defect mask is control. In the metacognition literature, monitoring and control can fail independently (Fleming and Lau, 2014). A scorer can rank defective pixels correctly, i.e., have high metacognitive sensitivity, and still be paired with a threshold at the wrong level. Threshold-free metrics such as AU-PRO measure the former, while segmentation F1 depends on both. F1 therefore cannot show which of the two is responsible when performance changes.

To isolate the meta level, we keep the encoder of SuperADD (Roming et al., 2026), which won the VAND 4.0 challenge on MVTec AD 2. We replace its nearest-neighbor memory bank with a single Gaussian per layer and score each patch token by its Mahalanobis distance. The fitted model takes 52.47 MB across the four layers regardless of the size of the training set. It scores each token about 78 times more cheaply than nearest-neighbor search.

On MVTec AD 2, the two functions dissociate. The Mahalanobis scorer improves AU-PRO at 0.05 from 56.81 to 64.81. Under the dataset's threshold of the mean plus three standard deviations, however, its segmentation F1 drops to 19.88, against 33.34 for the memory bank, since that threshold is set by the center of the score distribution. Fitting the tail on normal images with Extreme Value Theory raises F1 by 29.51 points for the Mahalanobis scorer and by 16.66 for the memory bank, narrowing the gap between the two from 13.46 to 0.61 points without using any anomalous data. Across MVTec AD and VisA, the Mahalanobis scorer is then ahead, by 10.78 and 8.74 points respectively. Even at the oracle threshold, however, the memory bank keeps a 6.73-point lead on MVTec AD 2, so only part of the original deficit was due to threshold placement.

Segmentation F1 under two thresholds

  • Nearest neighbor
  • Mahalanobis
Segmentation F1 (%)0204060μ+3σ, Nearest neighbor: 33.34μ+3σ, Mahalanobis: 19.88EVT t c, Nearest neighbor: 50.00EVT t c, Mahalanobis: 49.3933.3419.8850.0049.39μ+3σEVT tc
Data table
Nearest neighborMahalanobis
μ+3σ33.3419.88
EVT tc50.0049.39

Table 1 of the paper, MVTec AD 2, mean of 3 seeds.

Better monitoring, in this setting, translates into better decisions only once control is calibrated to it. As such, the paper recommends evaluating and reporting threshold calibration separately from ranking quality.

Thresholds in industrial inspection

On a production line, a decision is what stops a part. An anomaly map that orders pixels well still has to be turned into a binary defect mask, and that is where an inspection system commits to an action. Many anomaly detection papers report only the best F1 reachable by sweeping the threshold over the labeled test set (F1max), which describes ranking quality only. The default of MVTec AD 2, the mean plus three standard deviations of scores on defect-free images, is a deployable rule, yet it implicitly assumes a Gaussian score tail. Fitting the tail directly with Extreme Value Theory (EVT) needs only defect-free images and a chosen false-positive budget.

Deployment constraints add a second reason to care about the scorer. For the ViT-H+ backbone on MVTec AD 2, a nearest-neighbor memory bank must be stored and searched for every token, whereas the Gaussian model stays at 52.47 MB regardless of the training set. This makes it relevant to latency- and memory-constrained industrial anomaly detection.

How it connects to other anomaly detection work

The two scorers belong to two well-known families. Memory-bank methods such as PatchCore (Roth et al., 2022) store normal patch features and score by nearest-neighbor distance, whereas parametric methods summarize normality with a statistical model, as in Rippel et al. (2021) and PaDiM (Defard et al., 2021). Our contribution is to keep the DINOv3 backbone fixed so that the effect of the scorer can be read on its own, which is the kind of control that foundation-model anomaly detection needs now that encoders and scorers evolve in parallel. The distinction between ranking and deciding also applies to out-of-distribution detection more broadly. Any detector that raises an alarm must choose a threshold, so the threshold-free and thresholded views can disagree there as well.

An open question is how benchmarks should report the two sides. If a method is credited only for its ranking, a better scorer may look worse in production. If it is credited only for its F1 at a default threshold, a better scorer may look worse in the paper.

The same two-level reading frames our framework for test-time adaptation, presented at the same symposium.

References

Cite

BibTeX
@article{Galiazzo_2026, title={A Metacognitive Perspective on Anomaly Detection with Vision Foundation Models}, volume={10}, ISSN={2994-4317}, url={http://dx.doi.org/10.1609/aaaiss.v10i1.43397}, DOI={10.1609/aaaiss.v10i1.43397}, number={1}, journal={Proceedings of the AAAI Symposium Series}, publisher={Association for the Advancement of Artificial Intelligence (AAAI)}, author={Galiazzo, Matteo and Onorato, Gabriele and Loi, Dario and Bastian, Nathaniel D. and Restuccia, Francesco}, year={2026}, month=Nov, pages={110--114} }