Paper deep dive
Anlu: Enabling In-Context Time Series Anomaly Detection in Foundation Models via Counterfactual Supervision
Tian Lan, Yifei Gao, Yimeng Lu, Xuming An, Meng Wang, Yue Pan, Wenjun He, Chen Zhang
Intelligence
Status: not_run | Model: - | Prompt: - | Confidence: 0%
Entities (0)
Relation Signals (0)
No relation signals yet.
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
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.
Tags
Links
- Source: https://arxiv.org/abs/2610.06180v1
- Canonical: https://arxiv.org/abs/2610.06180v1
Trouble viewing inline? Open PDF directly →
Full Text
33,723 characters extracted from source content.
Expand or collapse full text
Anlu: Enabling In-Context Time Series Anomaly Detection in Foundation Models via Counterfactual Supervision Tian Lan 1 Yifei Gao 1 Yimeng Lu 1 Xuming An 1 Meng Wang 2 Yue Pan 2 Wenjun He 2 Chen Zhang 1∗ 1 Department of Industrial Engineering, Tsinghua University 2 Huawei gao-yf@mail.tsinghua.edu.cn lant23,luym25,axm24@mails.tsinghua.edu.cn wangmeng71,panyue33,hewenjun8@huawei.com Preprint 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. 1 arXiv:2610.06180v1 [cs.LG] 5 Oct 2026 Anlu: In-Context Time Series Anomaly DetectionPreprint Normal referenceSame query xTraining target r 1 Event every cycle y 1 : anomalous r 2 Skipped events allowed y 2 : normal Evaluated interval Figure 1: One fixed query under two normal references. The orange span is the evaluated query interval. Referencer 1 repeats the scheduled event on every cycle, so the missing query event is anomalous. Referencer 2 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 belowlog2 (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 log 2 (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). 2 Related Work Time-series foundation models. Pretrained TSFMs transfer temporal representations across datasets without per-dataset training. TimesFM, Chronos, Moirai, and Toto target zero-shot forecasting, and MOMENT covers forecasting, classification, imputation, and anomaly detection with one pretrained model [2,4,5,7,15]. Zero-shot anomaly detectors pretrain on multi-domain or synthetic data and score a query window directly. DADA uses adaptive bottlenecks and dual adversarial decoders [13], and TimeRCD learns pointwise scores from relative context discrepancy [8]. These detectors infer normal behavior from the query window itself and accept no separate record of normal operation. TSFMs have begun to use series beyond the target: in-context fine-tuning prompts TimesFM with examples from related series [6]. The forecasting target is still the future 2 Anlu: In-Context Time Series Anomaly DetectionPreprint 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 Letx∈ R T×C be a query of lengthTandr ∈ R L×C a reference of lengthLover the sameCchannels. Their lengths can differ and their samples need not be aligned. Given frozen parametersθ 0 and adaptation parameters φ, the detector returns a score for every query time, s = f θ 0 ,φ (x,r)∈ [0, 1] T .(1) For synthetic tasks, a normal rule defines admissible behavior, and the binary conditional labely r ∈0,1 T of the query follows that rule and the evidence realized in reference r. A counterfactual unit contains one query and two labeled references, τ i = (x i ,r a i ,y a i ,r b i ,y b i ), D i =t∈ V a i ∩ V b i : y a i,t ̸= y b i,t ,(2) whereV a i andV b i are the valid labeled positions andD i collects positions whose labels differ. The generator keeps units withD i ̸=∅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 probabilityp∈(0,1) to a positiont∈D i in both branches. Its equally weighted cross-entropy at t is − 1 2 logp− 1 2 log(1− p)≥ log 2,(3) with equality at p = 1/2. A loss below log 2 at t 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 channelc, the reference encoder produces patch representationsR c ∈ R P r ×d . A trainable Perceiver-style resampler, as in Flamingo [1], maps them to a memory of K tokens, M c =R φ (R c ;m r )∈ R K×d ,(4) whereP r is the number of reference patches,dis the encoder width, andm r marks the unpadded reference patches. Each adapted query-encoder depth reads this memory with its own interaction parameters. 3 Anlu: In-Context Time Series Anomaly DetectionPreprint (b) Gated adapter A ℓ H ℓ Q M K, V Norm + cross-attention ×tanh(α ℓ ) + Norm + FFN ×tanh(β ℓ ) + H′ H out Shared across adapters Query encoder with adapters Patch embedding Blocks 1–3 A 3 Blocks 4–5 A 5 Blocks 6–7 A 7 Block 8 A 8 Perceiver resampler Learned latents Reference encoder Patch embedding Frozen TSFM (a) Anlu architecture During adaptation: FrozenTrainable Reference r Query x Scores s Reference features (variable length) ... Reference memory M 32 tokens per channel ... Projection + detection head 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 H ℓ,c after frozen block ℓ, an adapter applies H ′ ℓ,c = H ℓ,c + tanh(α ℓ )A ℓ (H ℓ,c ,M c ), e H ℓ,c = H ′ ℓ,c + tanh(β ℓ )F ℓ (H ′ ℓ,c ), (5) whereA ℓ is normalized cross-attention with an output projection andF ℓ 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,u t,c,1 andu t,c,0 . Their difference defines the anomaly logit and score, a t = 1 C C X c=1 (u t,c,1 − u t,c,0 ), s t = sigmoid(a t ).(6) 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μ c and population standard deviationσ c of the full query are computed before cropping and applied to both series: ̄x t,c = x t,c − μ c η c , ̄r t ′ ,c = r t ′ ,c − μ c η c , η c = max(σ c , 10 −4 ).(7) The shared query statistics preserve the relative scale of the two series. Heretindexes the query andt ′ 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. 4 Anlu: In-Context Time Series Anomaly DetectionPreprint For a minibatchB, letV i be the valid labeled times of examplei. The detection loss is the mean binary cross-entropy over those times, L det =− X i∈B X t∈V i [y i,t logs i,t + (1− y i,t ) log(1− s i,t )] X i∈B |V i | .(8) The frozen reconstruction head predicts the normalized, unmasked query at the masked valid positionsM. The training objective is L(φ) =L det (φ) + 1 |M|C X (i,t)∈M C X c=1 (bx i,t,c − ̄x i,t,c ) 2 .(9) AdamW trains φ at batch size 24, with a constant learning rate of 10 −4 and weight decay 10 −5 . 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 boundarybfor each sequence. The reference is the firstmin(b,10,000) 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. 5 Anlu: In-Context Time Series Anomaly DetectionPreprint 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. ModelIOPS MGAB NAB NEK Power SED TODS UCR WSD YAHOO Avg. rank ↓1st 2nd3rd Retained series169265132 228 105137 VUS-PR↑ Zero-shot models TimeRCD42.363.09 44.06 96.68 14.63 69.8699.27 27.4830.50 92.212.40 2 42 DADA24.66 ∗ 0.57 ∗ 23.17 48.24 10.61 6.42 24.42 2.94 33.43 83.89 ∗ 8.29 7 0 01 MOMENT38.57 ∗ 0.56 ∗ 41.51 ∗ 81.34 10.50 4.31 20.00 6.17 54.61 43.39 ∗ 8.83 6 1 00 TimesFM18.55 0.58 21.99 36.53 10.44 6.13 29.69 6.03 21.80 90.058.70 0 01 Chronos18.50 0.60 21.88 33.42 10.95 8.65 27.52 6.56 19.00 85.707.85 0 00 Time-MoE16.76 0.52 20.87 23.94 9.34 10.87 17.27 2.10 11.08 28.8511.60 0 01 MovingVar.22.87 0.44 46.53 53.53 10.70 5.17 19.83 6.90 22.85 27.658.50 0 01 Full-shot models TranAD20.39 0.64 24.61 89.28 13.04 5.75 14.55 2.25 12.62 35.788.90 0 00 USAD16.40 0.75 51.9588.59 18.684.37 37.21 8.85 10.07 19.457.10 0 22 OmniAnomaly 25.250.64 26.17 92.92 14.32 6.20 13.94 2.40 16.85 40.947.40 0 01 LOF19.82 0.57 19.79 84.97 9.31 6.81 14.71 2.39 13.00 58.2610.60 0 00 IForest8.18 0.62 21.46 89.85 11.56 7.71 18.86 2.88 2.10 13.7610.00 0 00 Sub-PCA23.61 0.60 43.95 97.6010.49 3.72 29.92 12.92 16.78 23.087.55 0 11 DCdetector5.18 0.59 16.49 18.36 12.32 9.37 21.97 1.53 3.26 11.6311.70 0 00 TFMAE4.82 0.64 16.08 20.41 11.90 9.55 18.36 2.57 5.41 38.5410.40 0 00 Anlu50.531.7652.5699.4625.5976.3876.4956.4243.3992.581.30730 Standard-F1↑ Zero-shot models TimeRCD46.19 8.63 42.57 92.58 23.12 60.85 91.97 33.4741.4289.632.50 3 23 DADA32.88 ∗ 0.80 ∗ 25.80 51.05 15.99 2.69 19.16 3.36 45.04 86.43 ∗ 10.57 7 0 10 MOMENT31.58 ∗ 0.67 ∗ 41.52 ∗ 74.65 16.39 3.36 15.76 9.00 41.41 12.30 ∗ 9.33 6 0 00 TimesFM34.57 0.83 24.56 39.12 16.73 2.96 19.84 7.86 38.45 85.108.85 0 01 Chronos33.13 0.99 24.33 34.49 17.47 8.74 15.41 8.21 34.47 77.789.10 0 00 Time-MoE27.67 0.45 25.05 11.46 12.16 17.73 19.06 4.09 20.18 36.1211.05 0 01 MovingVar.23.92 0.74 49.92 67.91 19.94 9.60 19.74 9.51 22.56 14.078.20 0 01 Full-shot models TranAD33.28 1.46 27.42 87.22 22.36 2.63 14.44 4.40 20.406.329.40 0 00 USAD30.55 3.89 53.53 91.30 28.243.41 32.85 10.74 13.139.256.40 1 11 OmniAnomaly 46.851.44 27.79 92.25 23.50 0.43 13.33 5.11 29.87 30.187.50 0 11 LOF32.00 1.05 23.20 80.62 12.18 4.11 15.94 4.70 22.55 62.889.90 0 00 IForest8.72 0.73 27.70 90.84 19.77 3.81 20.08 4.09 2.152.9510.65 0 00 Sub-PCA35.74 0.83 45.09 94.8016.05 9.56 29.04 15.12 25.39 11.816.65 0 11 DCdetector5.31 1.21 24.67 22.33 21.10 10.54 32.91 3.18 4.633.9710.30 0 01 TFMAE9.68 0.97 24.68 19.62 20.14 11.87 20.05 2.83 15.48 29.2310.20 0 00 Anlu55.208.1751.2496.0432.6658.1567.8758.3845.0589.871.40640 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. 6 Anlu: In-Context Time Series Anomaly DetectionPreprint Table 1: Univariate results with anomaly-free training prefixes, continued. ModelIOPS MGAB NAB NEK Power SED TODS UCR WSD YAHOO Avg. rank ↓1st 2nd3rd Retained series169265132 228 105137 F1-T↑ Zero-shot models TimeRCD45.40 9.05 49.40 90.50 23.05 60.59 89.22 41.1844.7073.382.60 3 22 DADA43.25 ∗ 0.91 ∗ 34.94 50.58 19.80 9.56 22.76 7.22 48.47 86.15 ∗ 10.00 7 1 00 MOMENT34.39 ∗ 0.80 ∗ 49.11 ∗ 74.52 19.91 9.54 26.62 13.02 42.06 13.87 ∗ 8.33 6 0 01 TimesFM49.290.93 35.13 36.49 19.80 9.58 30.20 10.78 41.58 84.187.70 1 10 Chronos46.011.10 34.33 33.66 19.90 13.18 27.01 10.88 39.96 78.067.20 0 11 Time-MoE26.67 0.63 36.31 12.44 19.85 17.73 22.46 8.29 22.77 52.889.70 0 01 MovingVar.23.64 0.85 54.93 63.78 19.93 9.59 21.68 12.85 22.02 14.738.90 0 01 Full-shot models TranAD22.07 1.65 36.12 82.19 22.36 9.57 20.63 7.75 21.227.219.60 0 00 USAD21.21 4.07 59.20 84.28 28.23 9.54 39.53 14.63 14.289.346.85 1 12 OmniAnomaly 53.04 1.61 37.79 87.37 23.48 9.68 20.98 8.47 35.41 30.796.40 1 01 LOF29.48 1.15 33.37 75.13 19.80 9.60 21.42 8.31 24.28 68.879.10 0 00 IForest7.87 0.84 19.76 83.04 0.00 9.54 12.07 6.36 4.452.6013.85 0 00 Sub-PCA34.46 0.98 51.13 94.80 20.30 9.54 29.72 18.90 25.31 12.307.05 0 11 DCdetector6.77 1.32 32.25 22.44 21.13 10.53 33.66 6.62 7.444.8510.50 0 00 TFMAE20.13 1.07 32.00 19.45 20.18 11.82 21.25 5.90 19.15 31.0011.20 0 00 Anlu44.697.2957.8495.4433.0957.5968.6558.0442.0664.702.45341 Affiliation-F↑ Zero-shot models TimeRCD87.34 74.54 93.6099.66 85.02 88.99 99.04 84.3490.74 98.382.00 5 22 DADA90.13 ∗ 67.66 ∗ 85.71 97.35 69.79 65.18 82.17 72.21 93.74 96.02 ∗ 8.57 7 0 10 MOMENT88.67 ∗ 66.76 ∗ 89.74 ∗ 94.94 75.97 59.13 62.07 75.77 95.22 86.71 ∗ 7.83 6 1 00 TimesFM81.86 66.95 78.58 93.30 69.88 67.14 86.02 70.03 79.00 91.799.30 0 00 Chronos90.4167.89 85.92 97.44 69.72 67.89 93.27 74.35 90.79 97.395.90 0 12 Time-MoE77.02 67.23 79.33 86.64 71.19 60.98 58.58 73.56 80.24 75.7710.60 0 00 MovingVar.84.93 67.56 91.06 89.91 74.77 67.14 82.97 78.44 89.25 84.226.10 0 01 Full-shot models TranAD83.63 67.28 89.65 99.33 71.56 61.03 59.07 73.31 84.91 83.788.30 0 00 USAD71.39 67.81 90.96 85.80 76.48 55.60 75.81 76.00 65.70 60.169.90 0 00 OmniAnomaly 81.05 67.35 91.83 99.76 78.16 61.26 56.99 73.53 78.96 79.768.25 0 12 LOF82.34 68.44 73.97 99.31 66.76 63.85 58.42 73.53 81.28 84.388.95 0 01 IForest52.75 68.8239.17 85.78 0.00 70.09 41.83 50.56 42.66 31.1412.80 0 10 Sub-PCA75.61 66.90 88.51 99.03 71.37 67.14 83.80 76.66 76.72 75.188.60 0 00 DCdetector72.05 67.91 71.40 73.57 69.75 72.20 73.84 70.18 72.73 70.4211.10 0 01 TFMAE78.60 67.50 75.32 86.19 70.30 68.17 69.62 70.60 79.92 84.109.70 0 00 Anlu93.3165.3594.3499.8084.2588.8393.6293.5492.4898.252.90441 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. 7 Anlu: In-Context Time Series Anomaly DetectionPreprint 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 conditionMean VUS-PR Frozen TSFM, no reference pathway0.542 Anlu, reference set to zero after normalization0.499 Anlu, original reference prefix0.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]. Anlu (ours) Time-RCD+ MAFT (FT) TSPulse (FT) Time-RCDCHARMTSPulse (ZS) StreamVAE 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 Mean VUS-PR ↑ 0.61 0.59 0.55 0.52 0.50 0.48 0.45 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. 8 Anlu: In-Context Time Series Anomaly DetectionPreprint −1 0 1 Value (a) MSL 145 0.00 0.08 0.16 (b) UCR 419 0 20000 (c) UCR 417 0.0 0.4 0.8 (d) SMD 196 0.30.60.9 Time (10 3 samples) −3 0 3 Anomaly logit 567 Time (10 3 samples) −8 −4 0 56 Time (10 3 samples) −10 −5 0 26.427.228.0 Time (10 3 samples) −6 0 6 ReferenceZero referenceGround-truth anomaly 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 logitu 1 − u 0 . 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. 9 Anlu: In-Context Time Series Anomaly DetectionPreprint [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 familyNormal-reference evidenceConditional query judgment Transition speedRepeated transitions between state levelsWhether transition speed lies within the supported range Skipped statesAdjacent or multi-step state transitionsWhether a transition skips more states than the supported limit Attenuation or absenceEvent strengths and repeated admissible omissions Whether attenuation or omission is allowed at the relevant slot Event enhancementOrdinary and enhanced event strengthsWhether enhancement exceeds the supported envelope Timing shiftEvent offsets relative to the process cycleWhether timing lies outside the supported range Idle-interval eventsRepeated 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 strengthsv 1 ,...,v n at a scheduled event slot: I r = max 0, min j v j − δ , max j v j + δ , δ = 0.14.(10) 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 10 Anlu: In-Context Time Series Anomaly DetectionPreprint 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. ComponentSetting Input and encodersUnivariate input,C = 1. Separate query and reference encoders with the same initialization Encoder architecture8 blocks, width 512, 8 heads, feed-forward width 2,048 Patching and projectionPatch size 16, pointwise feature width 256 Position informationEncoder rotary embeddings, no added resampler position embeddings Reference memory32 tokens per channel, 1 resampling layer AdaptersAfter blocks 3, 5, 7, and 8, with both scalar gates initialized to zero Frozen parametersBoth encoders, pointwise projection, detection head, reconstruction head Trainable parametersReference resampler and gated adapters, including gates LossPointwise binary cross-entropy over valid positions plus masked-query MSE, with equal weights Normalization and cropsFull-query statistics shared with the reference, query crops up to 10,000 samples, reference crops of 90%–100% OptimizerAdamW, constant learning rate 10 −4 , weight decay 10 −5 , batch size 24 RegularizationDropout 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 1MSL 145530267–1,114 2UCR 4193,0004,968–7,412 3UCR 4172,7504,300–6,700 4SMD 1967,174 26,325–28,695 11