Instructions to use thu-sail-lab/Time-RCD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thu-sail-lab/Time-RCD with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="thu-sail-lab/Time-RCD", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("thu-sail-lab/Time-RCD", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
| #!/usr/bin/env python3 | |
| """Minimal Time-RCD inference example on synthetic data.""" | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| import numpy as np | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from time_rcd import TimeRCDDetector | |
| def main() -> None: | |
| rng = np.random.default_rng(42) | |
| length = 2048 | |
| data = rng.normal(size=length) | |
| # Inject a simple anomaly spike. | |
| data[1000:1010] += 8.0 | |
| detector = TimeRCDDetector.from_pretrained(variant="uni") | |
| scores = detector.predict(data) | |
| print(f"Input shape: {data.shape}") | |
| print(f"Score shape: {scores.shape}") | |
| print(f"Top-5 anomaly indices: {np.argsort(scores)[-5:][::-1]}") | |
| if __name__ == "__main__": | |
| main() | |