Skip to content

TripletAD: Weakly Supervised Anomaly Detection in Embedding Space with Rare Anomalies and Scarce Labels

Sumit Wadhwa, Souvik Nath

cs.LG

Abstract

As AI and agentic systems automate more processes with less human review, data is increasingly represented, and passed between systems, as embeddings produced by pre-trained models. Detecting rare deviations in these embeddings is becoming a critical guardrail, yet anomaly detection methods were largely developed for hand-built tabular features, where gradient-boosted trees remain the method of choice. We propose TripletAD, a weakly supervised detector for embedding spaces in which anomalies are rare. TripletAD learns a triplet-margin embedding in which every triplet contains an anomaly, so the few anomalies are reused across the entire training set instead of being diluted by it, and calibrates a linear scoring head with a partial cross-entropy on anomalies and a relative-contrast hinge that separates the mean scores of anomalous and normal samples. Across 28 embedding datasets spanning text, images, speech and industrial inspection, TripletAD is consistently among the best-performing methods, matching or exceeding established state-of-the-art weakly supervised detectors (DevNet, PReNet and DeepSAD), supervised contrastive learning and gradient-boosted trees, and it outperforms them when anomalies are rare. On naturally rare speech data it is 43% above the strongest baseline and more than twice the established detectors; at a 1% anomaly rate it has the highest mean AUCPR of seven methods, 20% above DevNet; and pooled over 74 rare-anomaly settings it has the best average rank, with statistically significant gains over every baseline. In a case study on AI-agent traces, it locates the failing step more often than all six baselines, with accuracy on par with or above that reported for frontier LLM judges, at 0.17 ms per step. The method needs no per-dataset tuning and is insensitive to its loss weights and training length.

Create a lesson