$ show thuml/Large-Time-Series-Model
This repository provides the official code, datasets, and checkpoints for the Timer family of large time series foundation models (Timer, Timer-XL, Sundial) from Tsinghua University. It implements a decoder-only Transformer architecture pre-trained on the Unified Time Series Dataset (UTSD) using the single-series sequence (S3) format. The code supports fine-tuning and evaluation on three downstream tasks: forecasting, segment-level imputation, and predictive anomaly detection. Data loading modules handle multiple time series formats (CSV, NPZ, TXT) with flexible windowing and scaling. The repository includes shell scripts for reproducible experiments across multiple datasets and data scarcity ratios. It also provides HuggingFace integration for zero-shot forecasting without training. While primarily a research codebase rather than a production application, it is well-structured with clean module separation and reusable components.
The LLM identified 4 files worth highlighting for reuse:
Provides a collection of embedding modules for time series, including PatchEmbedding for converting time series into patch tokens (crucial for the Timer architecture), PositionalEmbedding, TokenEmbedding, and various temporal embeddings. The PatchEmbedding class is self-contained, uses ReplicationPad1d for padding, and supports optional positional embeddings. It can be extracted and reused in other time series Transformer projects.
Contains CIDatasetBenchmark and CIAutoRegressionDatasetBenchmark classes that load time series from CSV, TXT, or NPZ files, apply scaling, and generate input-output windows for forecasting tasks. Supports multiple data types (ETTh, ETTm, PEMS, custom) with automatic border splitting, time feature encoding, and variable/stride/subset sampling. This is a reusable data pipeline for time series deep learning experiments, adaptable to different datasets with minimal modification.
Systematic time feature extraction using pandas DatetimeIndex. Maps frequency strings (e.g., 'H', 'T', 'S') to appropriate time features (hour of day, day of week, month of year, etc.) encoded as values between -0.5 and 0.5. The time_features_from_frequency_str function returns a list of appropriate feature extractors based on the frequency, making it reusable for any time series preprocessing pipeline.
Provides a clean collection of time series forecasting evaluation metrics: MAE, MSE, RMSE, MAPE, MSPE, RSE, CORR, NRMSE, WAPE, and a combined metric function. Each function is self-contained and operates on numpy arrays. This can be extracted as a standalone utility for any time series evaluation task.