Anomagic: Unified Anomaly Detection & Generation
- Anomagic Framework is a unified, model-independent system that defines anomalies by exhaustively modeling known objects, using veto strategies in collider physics and zero-shot inpainting in vision.
- The approach leverages advanced techniques such as Boosted Decision Trees and crossmodal prompt encoding to precisely separate standard objects from anomalies.
- Empirical benchmarks demonstrate high efficiency, with detection rates up to 90% in physics and pixel-wise F1 scores over 54% in vision, underscoring its robust performance.
The Anomagic framework encompasses both pioneering anomaly detection methodology for high energy physics (Chakraborty et al., 2017) and a state-of-the-art zero-shot anomaly generation architecture for computer vision (Jiang et al., 13 Nov 2025). Both systems are unified by the central philosophy of discriminating anomalous instances by rigorously modeling and excluding distributions of known or standard objects, then flagging anything outside these priors as anomalous. While the specific implementations differ radically across the domains of collider data and visual inpainting, both realize robust, model-independent strategies for identifying out-of-distribution phenomena.
1. Philosophical Foundation
The foundational principle of the Anomagic approach is that anomalies should be characterized not by modeling the unknown directly, but by exhaustively describing the known. In the context of the Large Hadron Collider (LHC), this translates to exhaustively identifying and vetoing jets consistent with standard object hypotheses—photons, electrons, taus, QCD jets—such that any jet escaping all such vetoes is declared anomalous (Chakraborty et al., 2017).
In anomaly generation for vision, Anomagic operates under the assumption that a generative model conditioned on crossmodal cues and precise mask localization can synthesize semantically coherent, mask-adherent, and diverse anomalies without explicit examples of real defects (Jiang et al., 13 Nov 2025). This unifying philosophy leverages deep prior knowledge of the standard or background class to drive rigorous assessment or augmentation of anomalous events.
2. The Anomagic Framework in High Energy Physics
Veto-Based Anomaly Finder
The original Anomagic framework for the LHC is a veto-based object identification scheme that proceeds as follows:
- All reconstructed objects—γ, e, τₕ, QCD jets, or non-standard—are reclustered into anti-kₜ jets (R=0.4, > 50 GeV), creating a universal phase-space for classification.
- The standard object phase-space is mapped in data using multidimensional descriptors: hadronic energy fraction (), track multiplicity , and a set of 10–12 jet substructure observables (e.g., -subjettiness, energy correlation functions).
- Boosted Decision Trees (BDTs) are trained pairwise to separate each standard object class, yielding response scores (, , ).
- In each phase-space segment , 3D histograms of BDT outputs are used to define tight vetoes with acceptance rates (QCD: 0.5%), .
- Any jet passing all veto masks is classified as anomalous.
Data-Driven Calibration and Performance
Control samples for each standard object are extracted from well-characterized physics processes and sidebands. Systematic stability is ensured by varying target rates, pile-up subtraction methods, and retraining across operational epochs. Efficiencies for detecting non-standard objects (collimated di-photons, -electrons, -taus) are ~60–90% depending on topology, with standard background mistag rates tightly controlled. The computational design enables deployment at the trigger level.
3. The Anomagic Zero-Shot Anomaly Generation Pipeline
Crossmodal Prompt Encoding
The computer vision incarnation of Anomagic introduces a Crossmodal Prompt Encoding (CPE) module to fuse visual and textual anomaly descriptions:
- The image encoder (frozen CLIP-ViT) extracts dense spatial features from a reference anomaly image .
- Mask-gated self-attention () ensures features focus on the defect by suppressing non-masked regions.
- The text encoder encodes a free-form caption , split and average-pooled if needed.
- The CrossFusion block combines and into a unified crossmodal prompt , used for downstream conditioning.
Inpainting-Based Generation
The anomaly generator is a Stable Diffusion-based inpainting model fine-tuned via LoRA (cross-attention layers only):
- Inputs: A normal image , inpainting mask , and conditioning prompt .
- At each diffusion timestep, noisy latents, the mask, and steer the model toward semantically-valid, mask-aligned, defect synthesis.
- The masked LDM loss enforces fidelity within ; an adversarial penalty can be added.
Contrastive Refinement
Post-generation, a contrastive alignment step ensures that synthesized defects exactly match the intended mask:
- Features from anomaly and mask regions are extracted by a lightweight encoder.
- The contrastive loss encourages alignment between the inpainted anomaly and its ground-truth mask, improving boundary precision.
AnomVerse Dataset
Training is conducted on AnomVerse, a 12,987-sample collection comprising anomaly-mask-caption triplets from 13 public datasets. Automatic captioning by a multimodal LLM using template-based structured hints ensures semantically rich, defect-grounded textual supervision.
4. Algorithmic and Implementation Specifics
Computer Vision Anomaly Generator
- Only the cross-attention layers of the UNet are fine-tuned, promoting efficient adaptation.
- Sampling and mask application allow zero-shot, cross-category anomaly synthesis.
- Inference speed: seconds per image on A100 GPU.
- No per-category fine-tuning is required; arbitrary prompts such as “cracks, bulges, scratches in cashews” are supported.
LHC Anomaly Finder
- Phase-space is partitioned using segmentation variables and BDT outputs, with binning at granularity.
- Each segment’s veto is calculated to leave only the specified residual acceptance.
- Computational efficiency enables deployment in online environments (HLT) at s per jet).
5. Quantitative Outcomes and Empirical Benchmarks
Computer Vision
- On VisA, Inception Score (IS) and Intra-cluster LPIPS (IL) for Anomagic: 2.16/0.394, outperforming prior zero-shot (AnomalyAny: 1.94/0.330) and few-shot (AnoGen: 2.10/0.390) methods.
- In downstream detection with INP-Former++, Anomagic achieves image-level ROC 99.08%, pixel-wise F1 54.00%—surpassing RealNet (52.87%) and AnoGen (52.61%) (Jiang et al., 13 Nov 2025).
High Energy Physics
- Non-standard object efficiencies: collimated di-photon jets 60–80%, di-electrons 80–90%, di-taus 15–20%.
- Standard object mistag rates: QCD , photons/electrons/taus .
- Algorithm robust to pile-up, segmentation choices, and systematic shifts in veto rates (Chakraborty et al., 2017).
6. Scope, Domain Transfer, and Significance
The Anomagic concept generalizes across domains. In collider physics, it operationalizes a robust, model-independent search for new physics—flagging any event with at least one outlier object. In the computer vision setting, Anomagic requires no anomalous exemplars during generation, instead fusing multi-modal, region-focused cues to produce diverse, mask-adherent, semantically-matched synthetic anomalies, providing high-fidelity augmentation for anomaly detection pipelines.
Both implementations demonstrate that rigorous modeling, exclusion, and conditioning on the known or background class is a scalable, principled route to anomaly discovery or augmentation—a paradigm validated by quantitative empirical superiority in both LHC physics searches and state-of-the-art visual anomaly detection.