Manuscript Offprint
arXiv:2610.06180Anlu: Enabling In-Context Time Series Anomaly Detection in Foundation Models via Counterfactual Supervision
Abstract
Whether a time-series pattern is anomalous often depends on the operating regime of the monitored process. A missing event can signal a fault in one regime and be routine in another, and the query alone may not reveal which regime applies. We study in-context learning (ICL) for time series anomaly detection (TSAD) through reference-conditioned detection, where a reference record provides evidence about expected behavior and model parameters remain fixed at inference. Supplying the reference is not enough: when training anomalies are recognizable from the query alone, the detector can fit its targets while ignoring the reference. We therefore introduce counterfactual supervision, which pairs one query with two references that support different normal rules and labels the query under each. At positions where the two labels disagree, no detector that ignores the reference can fit both targets. Anlu learns from this supervision by adding a reference memory and zero-initialized gated adapters to a frozen time-series foundation model (TSFM) pretrained for anomaly detection. On the 350 TSB-AD-U evaluation sequences, Anlu raises the mean VUS-PR of the frozen TSFM from 0.542 to 0.607. Replacing the reference with zeros lowers Anlu's score to 0.499.
Keywords: In-context learning, Time series anomaly detection, Reference conditioning, Counterfactual supervision
1 Introduction
Industrial monitoring judges a sensor stream against the normal behavior of the process that produced it. That behavior changes with products, loads, and maintenance schedules, and a pattern that is normal in one operating regime can be a fault in another. A missing pulse indicates a fault when the process must emit an event on every cycle, but it is routine when intermittent events are allowed. The query alone may not reveal which rule applies. Figure 1 keeps one query fixed and changes the normal reference against which it is judged.
We frame this setting as reference-conditioned in-context learning: the supplied reference provides evidence about expected behavior for anomaly scoring, while model parameters remain fixed.
Current detectors obtain regime information in one of two ways. Zero-shot detectors built on pretrained time-series foundation models (TSFMs) score a query from its own values and surrounding context [7, 8], so they cannot be told which regime applies. Semi-supervised detectors fit their parameters to normal data from the target series [10], so each new regime requires another round of training. Records of normal operation are easy to collect, whereas representative faults are rare. We study reference-conditioned detection, in which a separate
*Corresponding author: zhangchen01@tsinghua.edu.cn.
Preprint

Figure 1: One fixed query under two normal references. The orange span is the evaluated query interval. Reference repeats the scheduled event on every cycle, so the missing query event is anomalous. Reference repeats admissible omissions, so the same interval is normal. These labels are the conditional training targets.
normal record enters the detector as an input and specifies the regime at inference. Normal operation can then be demonstrated before any fault has been observed.
Adding a reference input does not ensure that the detector uses it. When a synthetic anomaly is recognizable from the query alone, training can reach a low loss with one rule for every reference. Counterfactual supervision removes this shortcut. Each training unit pairs one query with two references that support different normal rules and labels the query under each, so that some positions are anomalous under one reference and normal under the other. A detector that ignores the reference assigns the same score to such a position in both branches, and its mean cross-entropy there cannot fall below (Section 3.1). Fitting both labels therefore requires reading the reference.
Anlu adds this reference pathway to a frozen TSFM pretrained for pointwise anomaly detection. A resampler compresses the reference into a fixed-length memory, and gated adapters read that memory at four depths of the query encoder. Only the resampler and the adapters are trained. Because the gates start at zero, Anlu reproduces the frozen TSFM at initialization.
On the 350 TSB-AD-U evaluation sequences, Anlu raises the mean VUS-PR of the frozen TSFM from 0.542 to 0.607. To test whether this gain comes from the reference content, we keep the weights, queries, reference lengths, and validity masks fixed and set the normalized reference values to zero. The mean falls to 0.499, below the frozen TSFM, and the original reference scores higher on 248 of the 350 sequences.
Our contributions are as follows.
• We formulate reference-conditioned anomaly detection and introduce counterfactual supervision, in which one query receives conflicting labels under two references. At label-changing positions, any detector that ignores the reference incurs a cross-entropy of at least (Section 3.1).
• We present Anlu, which adds a reference memory and zero-initialized gated adapters to a frozen TSFM and trains only this pathway (Section 3.2).
• On TSB-AD-U, Anlu raises the mean VUS-PR of the frozen TSFM from 0.542 to 0.607, and a zero-reference intervention lowers it to 0.499 (Section 4).
Preprint
of the target series, so the examples can improve a forecast but do not change what is forecast. In Anlu, the reference determines the target itself, and the same query receives a different label when the reference supports a different normal rule.
In-context anomaly detection. In-context learning adapts a pretrained model to a task through examples in its input, with parameters fixed [3]. Several anomaly detectors adopt this interface. InCTRL scores an image by its residuals to a few normal sample prompts [16]. LLMAD retrieves similar normal and anomalous time-series segments as demonstrations for a large language model [9]. iAmTime trains a TSFM on demonstration episodes that include corrupted series paired with anomaly masks, and it selects the anomaly type per episode so that the demonstrations indicate which patterns count as anomalous [12]. In InCTRL and LLMAD, the label of a query is set by its own content, so the context can help detection without being necessary for it. iAmTime varies which anomaly types count across demonstrations. Anlu instead keeps the query fixed and varies the normal rule supported by a reference, and counterfactual supervision assigns labels that differ where the two references support different rules.
3 Method
3.1 Reference-conditioned tasks
Let be a query of length and a reference of length over the same channels. Their lengths can differ and their samples need not be aligned. Given frozen parameters and adaptation parameters , the detector returns a score for every query time,
For synthetic tasks, a normal rule defines admissible behavior, and the binary conditional label of the query follows that rule and the evidence realized in reference .
A counterfactual unit contains one query and two labeled references,
where and are the valid labeled positions and collects positions whose labels differ. The generator keeps units with and with reference evidence for both labels. It varies transition speed, skipped states, event strength or absence, timing, and activity at scheduled idle slots. Appendix A records the rule specification.
For example, the generator renders one query in which a scheduled event is suppressed. One reference repeats that event. The other repeats both occurrences and omissions. Absence of the event is anomalous under the first reference and normal under the second.
Conflicting labels exclude query-only solutions at label-changing positions. Suppose a deterministic detector ignores the reference and assigns the same probability to a position in both branches. Its equally weighted cross-entropy at is
with equality at . A loss below at therefore requires the score to depend on the reference.
3.2 Reference memory and gated detection
Anlu initializes the query encoder and the reference encoder from the same frozen TSFM. The TSFM is a Toto-style network [4] pretrained on a separate synthetic univariate corpus with masked-query reconstruction and pointwise anomaly classification. Adaptation freezes both encoders, the query pointwise projection, and the detection and reconstruction heads.
For channel , the reference encoder produces patch representations . A trainable Perceiver-style resampler, as in Flamingo [1], maps them to a memory of tokens,
where is the number of reference patches, d is the encoder width, and marks the unpadded reference patches. Each adapted query-encoder depth reads this memory with its own interaction parameters.
Preprint
(a) Anlu architecture

(b) Gated adapter
Figure 2: Anlu's framework. (a) The reference and query encoders use the same pretrained TSFM initialization. A Perceiver resampler compresses variable-length reference features into 32 memory tokens per channel. Adapters after query blocks 3, 5, 7, and 8 read the shared memory, and the frozen projection and detection head produce query-aligned scores. (b) Each adapter applies normalized cross-attention and a feed-forward block, each followed by a zero-initialized tanh gate and a residual connection. Blue denotes frozen modules and green denotes modules trained during adaptation.
Given query-patch representations after frozen block , an adapter applies
where is normalized cross-attention with an output projection and is a normalized feed-forward block. The scalar gates and start at zero, so the inserted adapter is an identity map at initialization.
The detection head returns two logits per time and channel, and . Their difference defines the anomaly logit and score,
The eight-block encoder has width 512 and patch size 16. A one-layer resampler produces 32 memory tokens per channel. Adapters follow blocks 3, 5, 7, and 8. Appendix B lists the full configuration.
3.3 Preprocessing and training
The synthetic training set contains about one million examples from reference-conditioned pairs and from anomaly-injection examples. For each channel, the mean and population standard deviation of the full query are computed before cropping and applied to both series:
The shared query statistics preserve the relative scale of the two series. Here indexes the query and indexes the reference.
Each stored example is cropped and masked on its own. A query crop contains at most 10,000 samples. If the query contains labeled anomalies, the crop includes a randomly chosen anomalous time with probability 0.5, and otherwise its start is uniform. A query with no labeled anomaly uses a uniform start. The reference crop is an independent contiguous interval of length 90% to 100% of the stored reference. Independent masks are applied to 15% of the query patches and 15% of the reference patches. Appendix B.1 gives the composition of the training set.
Preprint
For a minibatch , let be the valid labeled times of example . The detection loss is the mean binary cross-entropy over those times,
The frozen reconstruction head predicts the normalized, unmasked query at the masked valid positions . The training objective is
AdamW trains at batch size 24, with a constant learning rate of and weight decay .
4 Empirical Evaluation
4.1 Evaluation setup
We evaluate Anlu on the 350 sequences in TSB-AD-U Eval, from 23 source datasets [10]. The metric is VUS-PR, the volume under the precision-recall surface [11], and the reported value is the unweighted mean across sequences.
TSB-AD specifies a training boundary for each sequence. The reference is the first samples after rows with missing values are removed. Annotated anomalies occur in 35 of the 350 prefixes, and the reported mean includes those sequences.
The query is normalized once by its mean and population standard deviation, and the reference uses those statistics. The zero-reference condition then sets every normalized reference value to 0 and keeps the reference length and validity mask. Long queries are scored in overlapping windows, and anomaly logits are averaged on the overlaps. At inference the random patch mask is off, and padding is handled by the validity mask. Appendix B.2 gives the window length, stride, and metric implementation.
Univariate benchmark comparison. Table 1 starts from the 700 series in the 11 univariate datasets of TimeRCD Table 1 [8]. We exclude a series if any point in its designated training prefix has an anomaly label, so that the prefix used as reference contains no annotated anomalies. This removes 168 series and leaves 532 series from 10 datasets. We recompute the dataset means for every baseline from its archived per-series results on this same subset, and evaluate Anlu with a window of 10,000 and a stride of 1,500.
Preprint
Table 1: Univariate results after excluding series with anomalies in their training prefixes from the datasets in TimeRCD Table 1. The filter retains 532 series from 10 datasets; no Stock series remain. All models are aggregated over the same retained series. Each cell is the mean per-series score multiplied by 100. Ranks compare eligible models jointly across the zero-shot and full-shot groups.
| Model | Avg. rank | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| IOPS | MGAB | NAB | NEK | Power | SED | TODS | UCR | WSD | YAHOO | 1st | 2nd | 3rd | ||
| Retained series | 16 | 9 | 26 | 5 | 1 | 3 | 2 | 228 | 105 | 137 | ||||
| VUS-PR | ||||||||||||||
| Zero-shot models | ||||||||||||||
| TimeRCD | 42.36 | 3.09 | 44.06 | 96.68 | 14.63 | 69.86 | 99.27 | 27.48 | 30.50 | 92.21 | 2.40 | 2 | 4 | 2 |
| DADA | 24.66* | 0.57* | 23.17 | 48.24 | 10.61 | 6.42 | 24.42 | 2.94 | 33.43 | 83.89* | 8.29 | 0 | 0 | 1 |
| MOMENT | 38.57* | 0.56* | 41.51* | 81.34 | 10.50 | 4.31 | 20.00 | 6.17 | 54.61 | 43.39* | 8.83 | 1 | 0 | 0 |
| TimesFM | 18.55 | 0.58 | 21.99 | 36.53 | 10.44 | 6.13 | 29.69 | 6.03 | 21.80 | 90.05 | 8.70 | 0 | 0 | 1 |
| Chronos | 18.50 | 0.60 | 21.88 | 33.42 | 10.95 | 8.65 | 27.52 | 6.56 | 19.00 | 85.70 | 7.85 | 0 | 0 | 0 |
| Time-MoE | 16.76 | 0.52 | 20.87 | 23.94 | 9.34 | 10.87 | 17.27 | 2.10 | 11.08 | 28.85 | 11.60 | 0 | 0 | 1 |
| MovingVar. | 22.87 | 0.44 | 46.53 | 53.53 | 10.70 | 5.17 | 19.83 | 6.90 | 22.85 | 27.65 | 8.50 | 0 | 0 | 1 |
| Full-shot models | ||||||||||||||
| TranAD | 20.39 | 0.64 | 24.61 | 89.28 | 13.04 | 5.75 | 14.55 | 2.25 | 12.62 | 35.78 | 8.90 | 0 | 0 | 0 |
| USAD | 16.40 | 0.75 | 51.95 | 88.59 | 18.68 | 4.37 | 37.21 | 8.85 | 10.07 | 19.45 | 7.10 | 0 | 2 | 2 |
| OmniAnomaly | 25.25 | 0.64 | 26.17 | 92.92 | 14.32 | 6.20 | 13.94 | 2.40 | 16.85 | 40.94 | 7.40 | 0 | 0 | 1 |
| LOF | 19.82 | 0.57 | 19.79 | 84.97 | 9.31 | 6.81 | 14.71 | 2.39 | 13.00 | 58.26 | 10.60 | 0 | 0 | 0 |
| IForest | 8.18 | 0.62 | 21.46 | 89.85 | 11.56 | 7.71 | 18.86 | 2.88 | 2.10 | 13.76 | 10.00 | 0 | 0 | 0 |
| Sub-PCA | 23.61 | 0.60 | 43.95 | 97.60 | 10.49 | 3.72 | 29.92 | 12.92 | 16.78 | 23.08 | 7.55 | 0 | 1 | 1 |
| DCdetector | 5.18 | 0.59 | 16.49 | 18.36 | 12.32 | 9.37 | 21.97 | 1.53 | 3.26 | 11.63 | 11.70 | 0 | 0 | 0 |
| TFMAE | 4.82 | 0.64 | 16.08 | 20.41 | 11.90 | 9.55 | 18.36 | 2.57 | 5.41 | 38.54 | 10.40 | 0 | 0 | 0 |
| Anlu | 50.53 | 1.76 | 52.56 | 99.46 | 25.59 | 76.38 | 76.49 | 56.42 | 43.39 | 92.58 | 1.30 | 7 | 3 | 0 |
| Standard-F1 | ||||||||||||||
| Zero-shot models | ||||||||||||||
| TimeRCD | 46.19 | 8.63 | 42.57 | 92.58 | 23.12 | 60.85 | 91.97 | 33.47 | 41.42 | 89.63 | 2.50 | 3 | 2 | 3 |
| DADA | 32.88* | 0.80* | 25.80 | 51.05 | 15.99 | 2.69 | 19.16 | 3.36 | 45.04 | 86.43* | 10.57 | 0 | 1 | 0 |
| MOMENT | 31.58* | 0.67* | 41.52* | 74.65 | 16.39 | 3.36 | 15.76 | 9.00 | 41.41 | 12.30* | 9.33 | 0 | 0 | 0 |
| TimesFM | 34.57 | 0.83 | 24.56 | 39.12 | 16.73 | 2.96 | 19.84 | 7.86 | 38.45 | 85.10 | 8.85 | 0 | 0 | 1 |
| Chronos | 33.13 | 0.99 | 24.33 | 34.49 | 17.47 | 8.74 | 15.41 | 8.21 | 34.47 | 77.78 | 9.10 | 0 | 0 | 0 |
| Time-MoE | 27.67 | 0.45 | 25.05 | 11.46 | 12.16 | 17.73 | 19.06 | 4.09 | 20.18 | 36.12 | 11.05 | 0 | 0 | 1 |
| MovingVar. | 23.92 | 0.74 | 49.92 | 67.91 | 19.94 | 9.60 | 19.74 | 9.51 | 22.56 | 14.07 | 8.20 | 0 | 0 | 1 |
| Full-shot models | ||||||||||||||
| TranAD | 33.28 | 1.46 | 27.42 | 87.22 | 22.36 | 2.63 | 14.44 | 4.40 | 20.40 | 6.32 | 9.40 | 0 | 0 | 0 |
| USAD | 30.55 | 3.89 | 53.53 | 91.30 | 28.24 | 3.41 | 32.85 | 10.74 | 13.13 | 9.25 | 6.40 | 1 | 1 | 1 |
| OmniAnomaly | 46.85 | 1.44 | 27.79 | 92.25 | 23.50 | 0.43 | 13.33 | 5.11 | 29.87 | 30.18 | 7.50 | 0 | 1 | 1 |
| LOF | 32.00 | 1.05 | 23.20 | 80.62 | 12.18 | 4.11 | 15.94 | 4.70 | 22.55 | 62.88 | 9.90 | 0 | 0 | 0 |
| IForest | 8.72 | 0.73 | 27.70 | 90.84 | 19.77 | 3.81 | 20.08 | 4.09 | 2.15 | 2.95 | 10.65 | 0 | 0 | 0 |
| Sub-PCA | 35.74 | 0.83 | 45.09 | 94.80 | 16.05 | 9.56 | 29.04 | 15.12 | 25.39 | 11.81 | 6.65 | 0 | 1 | 1 |
| DCdetector | 5.31 | 1.21 | 24.67 | 22.33 | 21.10 | 10.54 | 32.91 | 3.18 | 4.63 | 3.97 | 10.30 | 0 | 0 | 1 |
| TFMAE | 9.68 | 0.97 | 24.68 | 19.62 | 20.14 | 11.87 | 20.05 | 2.83 | 15.48 | 29.23 | 10.20 | 0 | 0 | 0 |
| Anlu | 55.20 | 8.17 | 51.24 | 96.04 | 32.66 | 58.15 | 67.87 | 58.38 | 45.05 | 89.87 | 1.40 | 6 | 4 | 0 |
First, second, and third place are highlighted per dataset. * preserves the source table's ranking exclusions for DADA and MOMENT. Excluded cells enter neither average ranks nor counts; a subscript gives the number of ranked datasets when fewer than 10.
Preprint
Table 1: Univariate results with anomaly-free training prefixes, continued.
| Model | Avg. rank | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| IOPS | MGAB | NAB | NEK | Power | SED | TODS | UCR | WSD | YAHOO | 1st | 2nd | 3rd | ||
| Retained series | 16 | 9 | 26 | 5 | 1 | 3 | 2 | 228 | 105 | 137 | ||||
| F1-T | ||||||||||||||
| Zero-shot models | ||||||||||||||
| TimeRCD | 45.40 | 9.05 | 49.40 | 90.50 | 23.05 | 60.59 | 89.22 | 41.18 | 44.70 | 73.38 | 2.60 | 3 | 2 | 2 |
| DADA | 43.25* | 0.91* | 34.94 | 50.58 | 19.80 | 9.56 | 22.76 | 7.22 | 48.47 | 86.15* | 10.00 | 1 | 0 | 0 |
| MOMENT | 34.39* | 0.80* | 49.11* | 74.52 | 19.91 | 9.54 | 26.62 | 13.02 | 42.06 | 13.87* | 8.33 | 0 | 0 | 1 |
| TimesFM | 49.29 | 0.93 | 35.13 | 36.49 | 19.80 | 9.58 | 30.20 | 10.78 | 41.58 | 84.18 | 7.70 | 1 | 1 | 0 |
| Chronos | 46.01 | 1.10 | 34.33 | 33.66 | 19.90 | 13.18 | 27.01 | 10.88 | 39.96 | 78.06 | 7.20 | 0 | 1 | 1 |
| Time-MoE | 26.67 | 0.63 | 36.31 | 12.44 | 19.85 | 17.73 | 22.46 | 8.29 | 22.77 | 52.88 | 9.70 | 0 | 0 | 1 |
| MovingVar. | 23.64 | 0.85 | 54.93 | 63.78 | 19.93 | 9.59 | 21.68 | 12.85 | 22.02 | 14.73 | 8.90 | 0 | 0 | 1 |
| Full-shot models | ||||||||||||||
| TranAD | 22.07 | 1.65 | 36.12 | 82.19 | 22.36 | 9.57 | 20.63 | 7.75 | 21.22 | 7.21 | 9.60 | 0 | 0 | 0 |
| USAD | 21.21 | 4.07 | 59.20 | 84.28 | 28.23 | 9.54 | 39.53 | 14.63 | 14.28 | 9.34 | 6.85 | 1 | 1 | 2 |
| OmniAnomaly | 53.04 | 1.61 | 37.79 | 87.37 | 23.48 | 9.68 | 20.98 | 8.47 | 35.41 | 30.79 | 6.40 | 1 | 0 | 1 |
| LOF | 29.48 | 1.15 | 33.37 | 75.13 | 19.80 | 9.60 | 21.42 | 8.31 | 24.28 | 68.87 | 9.10 | 0 | 0 | 0 |
| IForest | 7.87 | 0.84 | 19.76 | 83.04 | 0.00 | 9.54 | 12.07 | 6.36 | 4.45 | 2.60 | 13.85 | 0 | 0 | 0 |
| Sub-PCA | 34.46 | 0.98 | 51.13 | 94.80 | 20.30 | 9.54 | 29.72 | 18.90 | 25.31 | 12.30 | 7.05 | 0 | 1 | 1 |
| DCdetector | 6.77 | 1.32 | 32.25 | 22.44 | 21.13 | 10.53 | 33.66 | 6.62 | 7.44 | 4.85 | 10.50 | 0 | 0 | 0 |
| TFMAE | 20.13 | 1.07 | 32.00 | 19.45 | 20.18 | 11.82 | 21.25 | 5.90 | 19.15 | 31.00 | 11.20 | 0 | 0 | 0 |
| Anlu | 44.69 | 7.29 | 57.84 | 95.44 | 33.09 | 57.59 | 68.65 | 58.04 | 42.06 | 64.70 | 2.45 | 3 | 4 | 1 |
| Affiliation-F | ||||||||||||||
| Zero-shot models | ||||||||||||||
| TimeRCD | 87.34 | 74.54 | 93.60 | 99.66 | 85.02 | 88.99 | 99.04 | 84.34 | 90.74 | 98.38 | 2.00 | 5 | 2 | 2 |
| DADA | 90.13* | 67.66* | 85.71 | 97.35 | 69.79 | 65.18 | 82.17 | 72.21 | 93.74 | 96.02* | 8.57 | 0 | 1 | 0 |
| MOMENT | 88.67* | 66.76* | 89.74* | 94.94 | 75.97 | 59.13 | 62.07 | 75.77 | 95.22 | 86.71* | 7.83 | 1 | 0 | 0 |
| TimesFM | 81.86 | 66.95 | 78.58 | 93.30 | 69.88 | 67.14 | 86.02 | 70.03 | 79.00 | 91.79 | 9.30 | 0 | 0 | 0 |
| Chronos | 90.41 | 67.89 | 85.92 | 97.44 | 69.72 | 67.89 | 93.27 | 74.35 | 90.79 | 97.39 | 5.90 | 0 | 1 | 2 |
| Time-MoE | 77.02 | 67.23 | 79.33 | 86.64 | 71.19 | 60.98 | 58.58 | 73.56 | 80.24 | 75.77 | 10.60 | 0 | 0 | 0 |
| MovingVar. | 84.93 | 67.56 | 91.06 | 89.91 | 74.77 | 67.14 | 82.97 | 78.44 | 89.25 | 84.22 | 6.10 | 0 | 0 | 1 |
| Full-shot models | ||||||||||||||
| TranAD | 83.63 | 67.28 | 89.65 | 99.33 | 71.56 | 61.03 | 59.07 | 73.31 | 84.91 | 83.78 | 8.30 | 0 | 0 | 0 |
| USAD | 71.39 | 67.81 | 90.96 | 85.80 | 76.48 | 55.60 | 75.81 | 76.00 | 65.70 | 60.16 | 9.90 | 0 | 0 | 0 |
| OmniAnomaly | 81.05 | 67.35 | 91.83 | 99.76 | 78.16 | 61.26 | 56.99 | 73.53 | 78.96 | 79.76 | 8.25 | 0 | 1 | 2 |
| LOF | 82.34 | 68.44 | 73.97 | 99.31 | 66.76 | 63.85 | 58.42 | 73.53 | 81.28 | 84.38 | 8.95 | 0 | 0 | 1 |
| IForest | 52.75 | 68.82 | 39.17 | 85.78 | 0.00 | 70.09 | 41.83 | 50.56 | 42.66 | 31.14 | 12.80 | 0 | 1 | 0 |
| Sub-PCA | 75.61 | 66.90 | 88.51 | 99.03 | 71.37 | 67.14 | 83.80 | 76.66 | 76.72 | 75.18 | 8.60 | 0 | 0 | 0 |
| DCdetector | 72.05 | 67.91 | 71.40 | 73.57 | 69.75 | 72.20 | 73.84 | 70.18 | 72.73 | 70.42 | 11.10 | 0 | 0 | 1 |
| TFMAE | 78.60 | 67.50 | 75.32 | 86.19 | 70.30 | 68.17 | 69.62 | 70.60 | 79.92 | 84.10 | 9.70 | 0 | 0 | 0 |
| Anlu | 93.31 | 65.35 | 94.34 | 99.80 | 84.25 | 88.83 | 93.62 | 93.54 | 92.48 | 98.25 | 2.90 | 4 | 4 | 1 |
First, second, and third place are highlighted per dataset. * preserves the source table's ranking exclusions for DADA and MOMENT. Excluded cells enter neither average ranks nor counts; a subscript gives the number of ranked datasets when fewer than 10.
Preprint
4.2 Results and reference intervention
Table 2 compares Anlu with the frozen TSFM and with the zero-reference condition. Anlu attains a mean VUS-PR of 0.607 with the original reference prefixes, 0.065 above the frozen TSFM at 0.542. Setting the reference to zero lowers Anlu's mean to 0.499. Relative to the zero-reference condition, the original prefix has the higher score on 248 sequences, the lower score on 82, and the same score on 20.
Table 2: Mean VUS-PR on all 350 TSB-AD-U Eval sequences under the protocol in Section 4.1.
| Model and reference condition | Mean VUS-PR |
|---|---|
| Frozen TSFM, no reference pathway | 0.542 |
| Anlu, reference set to zero after normalization | 0.499 |
| Anlu, original reference prefix | 0.607 |
The two Anlu conditions share weights, queries, reference lengths, and validity masks and differ only in the normalized reference values.
Figure 3 plots Anlu's mean VUS-PR beside six entries from the TSB-AD-U leaderboard snapshot retrieved on October 3, 2026 [14].

Figure 3: Mean VUS-PR on TSB-AD-U. The other six values come from the official leaderboard snapshot [14]. FT and ZS follow that snapshot's fine-tuned and zero-shot labels. Anlu uses the protocol in Section 4.1.
4.3 Score profiles
Figure 4 shows MSL 145, UCR 419, UCR 417, and SMD 196. The curves are merged anomaly logits from Anlu. None of the four reference prefixes contains an annotated anomaly. Appendix C lists the sequences, the display windows, and the selection rule.
5 Conclusion
Anlu freezes a pretrained anomaly detector and trains a reference memory with gated adapters at four encoder depths. For the synthetic tasks, one stored query is paired with two references, and each label follows the normal behavior of the accompanying reference.
On all 350 TSB-AD-U Eval sequences, Anlu attains a mean VUS-PR of 0.607 with the dataset reference prefixes, compared with 0.542 for the frozen TSFM. The zero-reference condition lowers Anlu's mean to 0.499.
Preprint
Reference --- Zero reference Ground-truth anomaly
(a) MSL 145

(b) UCR 419
(c) UCR 417
(d) SMD 196
Figure 4: Queries and anomaly logits for MSL 145, UCR 419, UCR 417, and SMD 196. The top row is the query signal. The bottom row is the anomaly logit . Solid blue curves use the original reference prefix. Dashed red curves set that prefix to zero after normalization. Gray bands mark annotated anomalies. The query, validity mask, and reference length are shared. Horizontal axes give sample indices in thousands.
References
[1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. Advances in neural information processing systems, 35:23716–23736, 2022.
[2] Abdul Fatir Ansari, Lorenzo Stella, Caner Turkmen, Xiyuan Zhang, Pedro Mercado, Huibin Shen, Oleksandr Shchur, Syama Sundar Rangapuram, Sebastian Pineda Arango, Shubham Kapoor, et al. Chronos: Learning the language of time series. arXiv preprint arXiv:2403.07815, 2024.
[3] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
[4] Ben Cohen, Emaad Khwaja, Youssef Doubli, Salahidine Lemaachi, Chris Lettieri, Charles Masson, Hugo Miccinilli, Elise Ramé, Qiqi Ren, Afshin Rostamizadeh, et al. This time is different: An observability perspective on time series foundation models. Advances in neural information processing systems, 38:50907–50951, 2026.
[5] Abhimanyu Das, Weihao Kong, Rajat Sen, and Yichen Zhou. A decoder-only foundation model for time-series forecasting. arXiv preprint arXiv:2310.10688, 2023.
[6] Abhimanyu Das, Matthew Faw, Rajat Sen, and Yichen Zhou. In-context fine-tuning for time-series foundation models. arXiv preprint arXiv:2410.24087, 2024.
[7] Mononito Goswami, Konrad Szafer, Arjun Choudhry, Yifu Cai, Shuo Li, and Artur Dubrawski. Moment: A family of open time-series foundation models. arXiv preprint arXiv:2402.03885, 2024.
[8] Tian Lan, Hao Duong Le, Jinbo Li, Wenjun He, Meng Wang, Chenghao Liu, and Chen Zhang. Towards foundation models for zero-shot time series anomaly detection: Leveraging synthetic data and relative context discrepancy. arXiv preprint arXiv:2509.21190, 2025.
[9] Jun Liu, Chaoyun Zhang, Jiaxu Qian, Minghua Ma, Si Qin, Chetan Bansal, Qingwei Lin, Saravan Rajmohan, and Dongmei Zhang. Large language models can deliver accurate and interpretable time series anomaly detection. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 2, pages 4623–4634, 2025.
[10] Qinghua Liu and John Paparrizos. The elephant in the room: Towards a reliable time-series anomaly detection benchmark. Advances in Neural Information Processing Systems, 37:108231–108261, 2024.
[11] John Paparrizos, Paul Boniol, Themis Palpanas, Ruey S Tsay, Aaron J Elmore, and Michael J Franklin. Volume under the surface: A new accuracy evaluation measure for time-series anomaly detection. Proc. VLDB Endow., 15(11):2774–2787, 2022.
Preprint
[12] Anish Saha and Konstantin Shmakov. A foundation model for instruction-conditioned in-context time series tasks. arXiv preprint arXiv:2603.22586, 2026.
[13] Qichao Shentu, Beibu Li, Kai Zhao, Yang Shu, Zhongwen Rao, Lujia Pan, Bin Yang, and Chenjuan Guo. Towards a general time series anomaly detector with adaptive bottlenecks and dual adversarial decoders. In International Conference on Learning Representations, volume 2025, pages 81358–81381, 2025.
[14] TSB-AD. Official TSB-AD leaderboard. https://thedatumorg.github.io/TSB-AD/static/leaderboard/TSB-AD-updated.html, 2026. Snapshot retrieved October 3, 2026.
[15] Gerald Woo, Chenghao Liu, Akshat Kumar, Caiming Xiong, Silvio Savarese, and Doyen Sahoo. Unified training of universal time series forecasting transformers. arXiv preprint arXiv:2402.02592, 2024.
[16] Jiawen Zhu and Guansong Pang. Toward generalist anomaly detection via in-context residual learning with few-shot sample prompts. In 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 17826–17836. IEEE, 2024.
A Conditional Rule Specification
Table 3 summarizes the six process-rule families. Within each family, waveform shape, period, phase, noise, and signal scale vary randomly. Each candidate unit renders one query and two references. A unit is accepted only if each reference repeats its rule often enough to support a judgment, the difference between the two rules is visible in the rendered waveform, the labels agree with the rules, and at least one query position changes its label.
Table 3: Process-rule families and their conditional targets.
| Rule family | Normal-reference evidence | Conditional query judgment |
|---|---|---|
| Transition speed | Repeated transitions between state levels | Whether transition speed lies within the supported range |
| Skipped states | Adjacent or multi-step state transitions | Whether a transition skips more states than the supported limit |
| Attenuation or absence | Event strengths and repeated admissible omissions | Whether attenuation or omission is allowed at the relevant slot |
| Event enhancement | Ordinary and enhanced event strengths | Whether enhancement exceeds the supported envelope |
| Timing shift | Event offsets relative to the process cycle | Whether timing lies outside the supported range |
| Idle-interval events | Repeated occupancy or absence at a scheduled slot | Whether an added event is admissible at that slot |
The event-strength rule uses an envelope of realized nonnegative strengths at a scheduled event slot:
The tolerance is measured in the generator's event-strength units, before the normalization in Equation (7). An absence counts as normal only if the reference shows at least two absences at that slot; an envelope that reaches zero does not by itself make an absence normal. The generator derives labels from the known schedule and the rendered waveform, and the detector receives neither.
B Implementation and Evaluation Details
B.1 Data and training
Each generation unit produces either a reference-conditioned pair, with probability 0.5, or a single anomaly-injection example. Because a pair contributes two labeled examples, about two thirds of the training examples are reference-conditioned. An anomaly-injection example contains a query with injected anomalies and no
Preprint
reference. It is paired with an all-zero raw record of the query length, which becomes a constant series after the query-based normalization in Equation (7).
Table 4 lists the model and optimization settings.
Table 4: Anlu configuration. Encoder block indices start at 1.
| Component | Setting |
|---|---|
| Input and encoders | Univariate input, . Separate query and reference encoders with the same initialization |
| Encoder architecture | 8 blocks, width 512, 8 heads, feed-forward width 2,048 |
| Patching and projection | Patch size 16, pointwise feature width 256 |
| Position information | Encoder rotary embeddings, no added resampler position embeddings |
| Reference memory | 32 tokens per channel, 1 resampling layer |
| Adapters | After blocks 3, 5, 7, and 8, with both scalar gates initialized to zero |
| Frozen parameters | Both encoders, pointwise projection, detection head, reconstruction head |
| Trainable parameters | Reference resampler and gated adapters, including gates |
| Loss | Pointwise binary cross-entropy over valid positions plus masked-query MSE, with equal weights |
| Normalization and crops | Full-query statistics shared with the reference, query crops up to 10,000 samples, reference crops of 90%-100% |
| Optimizer | AdamW, constant learning rate , weight decay , batch size 24 |
| Regularization | Dropout 0.1, independent 15% patch masks on the query and the reference |
B.2 Evaluation implementation
We use the official TSB-AD-U evaluation split of 350 univariate sequences. Reference prefixes range from 500 to 10,000 samples. Queries longer than 10,000 samples are scored in windows of 10,000 samples with stride 1,500, with a final window aligned to the end of the sequence, and overlapping anomaly logits are averaged.
VUS-PR is computed from the merged anomaly logits with the TSB-AD implementation and 250 score thresholds. Following TSB-AD, the maximum temporal tolerance of each sequence is set from its estimated dominant period.
C Reference-Effect Cases
Figure 4 shows four sequences on which the original-prefix condition has a higher VUS-PR than the zero-reference condition and the reference prefix contains no annotated anomaly. Each display window is centered on the annotated anomaly with the largest logit change between the two conditions, measured by the mean within-sequence percentile rank. Table 5 lists the sequences. The curves are computed with the protocol in Section 4.1 and then cropped for display.
Table 5: Sequences shown in Figure 4, from left to right. Display ranges are zero-based sample indices after rows with missing values are removed.
| Panel | Source | TSB-AD index | Reference length | Display range |
|---|---|---|---|---|
| 1 | MSL | 145 | 530 | 267–1,114 |
| 2 | UCR | 419 | 3,000 | 4,968–7,412 |
| 3 | UCR | 417 | 2,750 | 4,300–6,700 |
| 4 | SMD | 196 | 7,174 | 26,325–28,695 |