TL;DR
Most LLM-based anomaly detectors keep the language model in the scoring loop, repeatedly feeding it windows of data and asking it to spot anomalies. LLMDP-U flips this paradigm: it uses an LLM as a one-time detector compiler that reads a statistical summary of a time series' prefix and writes a custom, validated Python detector program. Once compiled, the LLM exits the stage completely—the resulting program runs numerically, achieving third place on the TSB-AD-U leaderboard without any time-series pretraining or fine-tuning.
What Problem Does This Paper Address?
Time-series anomaly detection (TSAD) is notoriously context-dependent. A sudden level shift, a broken seasonal cycle, and a strange new subsequence all require different detection biases, and no single algorithm wins across every dataset.
To handle this diversity without anomaly labels, researchers have generally taken one of two paths:
- Fixed detector pools, which apply predetermined statistical or geometric rules.
- Pretrained or fine-tuned time-series models, which learn transferable representations.
Recently, a third option emerged: using Large Language Models (LLMs) to adapt to each series. However, existing LLM detectors place the model inside the inference loop—constantly constructing prompts with raw values, windows, or plots for every scoring pass. LLMDP-U asks: Can we compile the LLM's series-specific reasoning once into a persistent, inspectable Python program, and leave the actual scoring to fast, deterministic math?
Methods
LLMDP-U separates one-time detector compilation from numerical score execution for univariate time series:
- Prefix Profiling: Instead of showing the LLM raw data, the system summarizes a benchmark-provided reference prefix ($x_{1:t_0}$) into a fixed-schema JSON profile. This includes marginal statistics, trend/seasonal descriptors, FFT periods, autocorrelation lags, change-point segments, and candidate window scales.
- Detector-Program Synthesis: The LLM receives the JSON profile, a code-generation contract, and an interface to
shape_lib—a library of six core subsequence primitives (matrix-profile discord, dictionary kNN distance, template normalized cross-correlation, subsequence PCA reconstruction, cycle residual, and shape changepoint). It then writes a Python function that outputs a $T \times M$ matrix of continuous anomaly scores, with no internal thresholding or voting allowed. - Validation: Before a program is kept, it undergoes syntax, import, and policy checks, plus a lightweight runtime sanity test on spiked and constant series. If it fails, the LLM gets feedback and retries. Once validated, the program is saved as a persistent artifact.
- Score Execution & Label-Free Fusion: The retained Python program runs offline and transductively over the complete unlabeled series. A fixed, label-free fusion rule converts the $M$ score columns into a single anomaly score: it applies tie-aware percentile ranking, weights each detector using PostShare (which favors detectors whose above-reference spikes occur after the prefix boundary), and averages the top-$\lceil\sqrt{M}\rceil$ weighted ranks at each timestamp.
Datasets
The authors evaluate LLMDP-U on the univariate track of the TSB-AD benchmark (TSB-AD-U), using its official protocol and primary metric, Average VUS-PR (Volume Under the Surface – Precision-Recall):
- Tuning-48: A 48-series split used exclusively to develop the synthesis prompt, aggregation rule, and PostShare weighting coefficient ($\alpha = 0.50$).
- Eval-350: A 350-series evaluation split spanning 23 source datasets and 9 application domains (including industrial monitoring, web services, and healthcare).
Key Insights and Ideas
- Stronger compilers matter—bank size alone doesn't: Under a shared protocol, performance climbs steadily from Haiku 4.5 (0.4881) to Sonnet 5 (0.5130) to Opus 5 (0.5498). Meanwhile, an
Exhaustive shape_libcontrol that mechanically instantiates all six primitives at every scale—matching Opus's bank size (35.13 vs. 34.90 columns)—only reaches 0.5016. - The detector scaffold drives the gain: On Tuning-48, summarizing the prefix into a profile cuts input tokens to 11.3% of the raw-prefix baseline with almost no change in VUS-PR (+0.0059). Adding the
shape_libinterface and program contract, however, boosts VUS-PR by +0.1752. - LLMs write novel detectors, not just library wrappers: An audit of 41,735 emitted columns across 1,194 retained programs shows that while 62.1% directly call
shape_libprimitives and 3.5% summarize them, 34.4% are custom compiler-written detectors. Neither subset alone recovers the full bank's accuracy (0.4844 for shape-only; 0.3628 for compiler-only). - Recurring profile-conditioned mechanisms: In zero-dominated series (like Series 827 / Exathlon 15), Opus repeatedly invents Occupancy (local activity rate) and nonmodal run-length (NMRL) (nonbackground-episode persistence) detectors. On Series 827, NMRL achieves 0.8648 VUS-PR compared to 0.5389 for unconditional dwell.
Key Results
TSB-AD-U Eval-350 Leaderboard
- Leaderboard standing: On TSB-AD-U Eval-350, LLMDP-U (Opus 5) achieves 0.5498 ± 0.0023 Average VUS-PR (and 0.9183 ± 0.0026 VUS-ROC), ranking 3rd overall without any time-series pretraining or fine-tuning—trailing only fine-tuned Time-RCD+MAFT (0.5856) and TSPulse (FT) (0.5516).
- Outperforming deterministic baselines: Opus-compiled programs beat a no-LLM Canonical Program by +0.0500 VUS-PR (95% CI: [+0.0344, +0.0656]) under Tuning-48-selected PostShare coefficients, and by +0.0452 (95% CI: [+0.0321, +0.0589]) under a shared $\alpha = 0.50$.
Limitations and Future Work
- Current constraints: LLMDP-U assumes a reference prefix is available, relies on offline transductive fusion (making it non-causal and non-streaming), targets only univariate series, and was evaluated on a single benchmark family.
- Latency: Compilation takes a median of 113.0 seconds of LLM generation per series, and each numerical scoring pass takes 23.0 seconds.
- Future directions: The authors plan to explore low-latency, online, and multivariate extensions, as well as compiling reusable detector programs that generalize across related series, domains, and sensors.
Summary updated