Time-RCD
August 1, 2026 Β· View on GitHub
Time-RCD
Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy
π°Β News | πΒ About | π―Β Use on Your Own Data | πΒ Project Structure | πΒ Citation
π° News
-
2026.05: Time-RCD has been accepted by ICML 2026. We also release the pre-trained dataset generation code and hyperparameters.
-
2026.04: With a new dataset and new checkpoints, Time-RCD achieves better results. The univariate setting improves VUS-PR by an absolute 6.7 points, and the multivariate setting improves VUS-PR by an absolute 4.5 points.
π About
Time-RCD is a zero-shot foundation model for time series anomaly detection. Given a univariate or multivariate series, it outputs a per-timestep anomaly score without any task-specific training on your data.
π On the TSB-AD benchmark, Time-RCD achieves a Univariate VUS-PR of 0.52 and a Multivariate VUS-PR of 0.32.
π Live Demo on Hugging Face Spaces β try Time-RCD interactively in your browser.
This repository contains:
time_rcd/β a lightweight Python API for inference on your own data
For a step-by-step guide, see Tutorial.md.
π― Use on Your Own Data
Installation
conda create -n Time-RCD python=3.10
conda activate Time-RCD
git clone https://github.com/thu-sail-lab/Time-RCD.git
cd Time-RCD
pip install .
Python API (recommended)
Checkpoints are downloaded from Hugging Face automatically on first use and cached locally.
For servers in China, set HF_ENDPOINT=https://hf-mirror.com before running
the examples or loading a checkpoint.
export HF_ENDPOINT=https://hf-mirror.com
import numpy as np
from time_rcd import TimeRCDDetector
data = np.load("my_series.npy") # shape (T,) or (T, C)
detector = TimeRCDDetector.from_pretrained(variant="uni") # or "multi"
scores = detector.predict(data) # shape (T,)
Multivariate series β use variant="multi" when C > 1:
detector = TimeRCDDetector.from_pretrained(variant="multi")
scores = detector.predict(multivariate_data) # shape (T, C) -> scores (T,)
Local checkpoint β if you already downloaded weights:
detector = TimeRCDDetector.from_local(
"best_model/pretrain_checkpoint_best_uni.pth",
variant="uni",
)
Quick example
python examples/quickstart.py
See Tutorial.md for CSV loading, hyperparameters, and more examples.
π Project Structure
.
βββ time_rcd/ # User-facing inference API
β βββ detector.py # TimeRCDDetector
β βββ _core/ # Time-RCD inference model implementation
βββ examples/
β βββ quickstart.py # Minimal inference example
βββ Tutorial.md # Guide for your own data
βββ pyproject.toml # Package metadata and dependencies
βββ zero-shot.png # Model overview
βββ README.md
TSB-AD benchmark code
The original benchmark integration, evaluation scripts, and baseline
implementations are maintained in the
tsb-ad-integration
branch. For the lightweight zero-shot inference API, use the main branch.
π Citation
If you find this work useful, please cite our paper:
@misc{lan2025foundationmodelszeroshottime,
title={Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy},
author={Tian Lan and Hao Duong Le and Jinbo Li and Wenjun He and Meng Wang and Chenghao Liu and Chen Zhang},
year={2025},
eprint={2509.21190},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2509.21190},
}