| 
1 |  | -# Understanding Different Design Choices in Training Large Time Series Models  | 
2 |  | -<img width="700" height="290" src="./imgs/ltsm_model.png">  | 
 | 1 | +# LTSM-Bundle: A Toolbox and Benchmark on Large Language Models for Time Series Forecasting  | 
 | 2 | + | 
 | 3 | +<div align="center">  | 
 | 4 | +<img src="./imgs/ltsm_model.png" width="700" height="290" alt="LTSM Model">  | 
 | 5 | +</div>  | 
3 | 6 | 
 
  | 
4 | 7 | [](https://github.com/daochenzha/ltsm/actions/workflows/test.yml)  | 
5 | 8 | 
 
  | 
6 |  | -This work investigates the transition from traditional Time Series Forecasting (TSF) to Large Time Series Models (LTSMs), leveraging universal transformer-based models. Training LTSMs on diverse time series data introduces challenges due to varying frequencies, dimensions, and patterns. We explore various design choices for LTSMs, including pre-processing, model configurations, and dataset setups. We introduce **Time Series Prompt**, a statistical prompting strategy, and $\texttt{LTSM-bundle}$, which encapsulates the most effective design practices identified. $\texttt{LTSM-bundle}$ is developed by [Data Lab at Rice University](https://cs.rice.edu/~xh37/).  | 
 | 9 | +> Empowering forecasts with precision and efficiency.  | 
 | 10 | +
  | 
 | 11 | +## Table of Contents  | 
 | 12 | + | 
 | 13 | +* [Overview](#overview)  | 
 | 14 | +* [Why LTSM-bundle](#why-ltsm-bundle)  | 
 | 15 | +* [Features](#features)  | 
 | 16 | +* [Installation](#installation)  | 
 | 17 | +* [Quick Start](#quick-start)  | 
 | 18 | +* [Project Structure](#project-structure)  | 
 | 19 | +* [Datasets and Prompts](#datasets-and-prompts)  | 
 | 20 | +* [Model Access](#model-access)  | 
 | 21 | +* [Cite This Work](#cite-this-work)  | 
 | 22 | +* [License](#license)  | 
 | 23 | +* [Acknowledgments](#acknowledgments)  | 
 | 24 | + | 
 | 25 | +---  | 
7 | 26 | 
 
  | 
8 |  | -## Resources  | 
9 |  | -:star2: Please star our repo to follow the latest updates on LTSM-bundle!  | 
 | 27 | +## Overview  | 
10 | 28 | 
 
  | 
11 |  | -:mega: We have released our [paper](https://arxiv.org/abs/2406.14045) and source code of LTSM-bundle-v1.0!  | 
 | 29 | +This work investigates the transition from traditional Time Series Forecasting (TSF) to Large Time Series Models (LTSMs), leveraging large transformer-based models like GPT. Training LTSMs on diverse time series data introduces challenges due to varying frequencies, dimensions, and patterns.  | 
12 | 30 | 
 
  | 
13 |  | -:books: Follow our latest [English Tutorial](https://github.com/daochenzha/ltsm/tree/main/tutorial) or [中文教程](https://zhuanlan.zhihu.com/p/708804309) to costomize your LTSM!  | 
 | 31 | +We explore multiple design choices, including pre-processing strategies, tokenization, model architectures, and dataset setups. We introduce:  | 
14 | 32 | 
 
  | 
15 |  | -:earth_americas: For more information, please visit:   | 
16 |  | -* Paper: [https://arxiv.org/abs/2406.14045](https://arxiv.org/abs/2406.14045)  | 
17 |  | -* Blog: [Time Series Are Not That Different for LLMs](https://towardsdatascience.com/time-series-are-not-that-different-for-llms-56435dc7d2b1)  | 
18 |  | -* Tutorial: [Build your own LTSM-bundle](https://github.com/daochenzha/ltsm/tree/main/tutorial)  | 
19 |  | -* Chinese Tutorial: [https://zhuanlan.zhihu.com/p/708804309](https://zhuanlan.zhihu.com/p/708804309)  | 
20 |  | -* Do you want to learn more about data pipeline search? Please check out our [data-centric AI survey](https://arxiv.org/abs/2303.10158) and [data-centric AI resources](https://github.com/daochenzha/data-centric-AI) !  | 
 | 33 | +* **Time Series Prompt**: A statistical prompting strategy  | 
 | 34 | +* **LTSM-bundle**: A toolkit encapsulating effective design practices  | 
 | 35 | + | 
 | 36 | +The project is developed by the [Data Lab at Rice University](https://cs.rice.edu/~xh37/).  | 
 | 37 | + | 
 | 38 | +---  | 
21 | 39 | 
 
  | 
22 | 40 | ## Why LTSM-bundle?  | 
23 |  | -The LTSM-bundle package leverages the HuggingFace transformers toolkit, offering flexibility to switch between different advanced language models as the backbone. It is easy to tailor the general LTSMs to their specific time series forecasting needs by selecting the most suitable language model from a wide array of options. The flexibility enhances the adaptability of the package across different industries and data types, ensuring optimal performance in diverse scenarios.  | 
 | 41 | + | 
 | 42 | +The LTSM-bundle leverages HuggingFace transformers, allowing flexible integration of large-scale pre-trained language models for time series tasks. Users can customize the pipeline to fit specific forecasting needs with minimal overhead, making it adaptable across various domains and industries.  | 
 | 43 | + | 
 | 44 | +Key highlights:  | 
 | 45 | + | 
 | 46 | +* Plug-and-play with GPT-style backbones  | 
 | 47 | +* Modular pipeline for easy experimentation  | 
 | 48 | +* Support for statistical and text prompts  | 
 | 49 | + | 
 | 50 | +---  | 
 | 51 | + | 
 | 52 | +## Features  | 
 | 53 | + | 
 | 54 | +| Category          | Highlights                                                                                                                          |  | 
 | 55 | +| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------- |  | 
 | 56 | +| ⚙ï¸ Architecture | Modular design, GPT-style transformers for time series                                                                              |  | 
 | 57 | +| 📝 Prompting      | Time Series Prompt & Text Prompt support                                                                                            |  | 
 | 58 | +| ⚡️ Performance    | GPU acceleration, optimized pipelines                                                                                               |  | 
 | 59 | +| 🔧 Integrations   | LoRA support, JSON/CSV-based dataset and prompt interfaces                                                                          |  | 
 | 60 | +| 🔬 Testing        | Unit and integration tests, GitHub Actions CI                                                                                       |  | 
 | 61 | +| 📊 Data           | Built-in data loaders, scalers, and tokenizers                                                                                      |  | 
 | 62 | +| 📂 Documentation  | Tutorials in [English](https://github.com/daochenzha/ltsm/tree/main/tutorial) and [Chinese](https://zhuanlan.zhihu.com/p/708804309) |  | 
 | 63 | + | 
 | 64 | +---  | 
24 | 65 | 
 
  | 
25 | 66 | ## Installation  | 
26 |  | -```  | 
 | 67 | + | 
 | 68 | +We recommend using Conda:  | 
 | 69 | + | 
 | 70 | +```bash  | 
27 | 71 | conda create -n ltsm python=3.8.0  | 
28 | 72 | conda activate ltsm  | 
29 |  | -git clone [email protected]:daochenzha/ltsm.git  | 
30 |  | -cd ltsm  | 
31 |  | -pip3 install -e .  | 
32 |  | -pip3 install -r requirements.txt  | 
33 | 73 | ```  | 
34 | 74 | 
 
  | 
35 |  | -## Quick Exploration on LTSM-bundle   | 
 | 75 | +Then install the package:  | 
36 | 76 | 
 
  | 
37 |  | -Training on **[Time Series Prompt]** and **[Linear Tokenization]**  | 
38 | 77 | ```bash  | 
39 |  | -bash scripts/train_ltsm_csv.sh  | 
 | 78 | +git clone https://github.com/datamllab/ltsm.git  | 
 | 79 | +cd ltsm  | 
 | 80 | +pip install -e .  | 
 | 81 | +pip install -r requirements.txt  | 
40 | 82 | ```  | 
41 | 83 | 
 
  | 
42 |  | -Training on **[Text Prompt]** and **[Linear Tokenization]**  | 
43 |  | -```bash  | 
44 |  | -bash scripts/train_ltsm_textprompt_csv.sh  | 
 | 84 | +---  | 
 | 85 | + | 
 | 86 | +## 🔧 Training Examples  | 
 | 87 | +<!-- Joshua please helps this part -->  | 
 | 88 | +```Python  | 
45 | 89 | ```  | 
46 | 90 | 
 
  | 
47 |  | -Training on **[Time Series Prompt]** and **[Time Series Tokenization]**  | 
48 |  | -```bash  | 
49 |  | -bash scripts/train_ltsm_tokenizer_csv.sh  | 
 | 91 | + | 
 | 92 | +## 🔍 Inference Examples  | 
 | 93 | + | 
 | 94 | +```Python  | 
 | 95 | +import os  | 
 | 96 | +import torch  | 
 | 97 | +import pandas as pd  | 
 | 98 | +from huggingface_hub import hf_hub_download  | 
 | 99 | +from safetensors.torch import load_file  | 
 | 100 | +from ltsm.models import LTSMConfig, ltsm_model  | 
 | 101 | + | 
 | 102 | +# Download model config and weights from Hugging Face  | 
 | 103 | +config_path  = hf_hub_download("LSC2204/LTSM-bundle", "config.json")  | 
 | 104 | +weights_path = hf_hub_download("LSC2204/LTSM-bundle", "model.safetensors")  | 
 | 105 | + | 
 | 106 | +# Load model and weights  | 
 | 107 | +model_config = LTSMConfig()  | 
 | 108 | +model_config.load(config_path)  | 
 | 109 | +model = ltsm_model.LTSM(model_config)  | 
 | 110 | + | 
 | 111 | +state_dict = load_file(weights_path)  | 
 | 112 | +model.load_state_dict(state_dict)  | 
 | 113 | + | 
 | 114 | +# Move model to device  | 
 | 115 | +device = torch.device("cuda" if torch.cuda.is_available() else "cpu")  | 
 | 116 | +model = model.to(device).eval()  | 
 | 117 | + | 
 | 118 | +# Load your dataset (e.g., weather)  | 
 | 119 | +df_weather = pd.read_csv("/path/to/dataset.csv")  | 
 | 120 | +print("Loaded data shape:", df_weather.shape)  | 
 | 121 | + | 
 | 122 | +# Load prompts per feature  | 
 | 123 | +feature_prompts = {}  | 
 | 124 | +prompt_dir = "/path/to/prompts/"  | 
 | 125 | +for feature, filename in {  | 
 | 126 | +    "T (degC)": "weather_T (degC)_prompt.pth.tar",  | 
 | 127 | +    "rain (mm)": "weather_rain (mm)_prompt.pth.tar"  | 
 | 128 | +}.items():  | 
 | 129 | +    prompt_tensor = torch.load(os.path.join(prompt_dir, filename))  | 
 | 130 | +    feature_prompts[feature] = prompt_tensor.squeeze(0).float().to(device)  | 
 | 131 | + | 
 | 132 | +# Predict (custom code here depending on your model usage)  | 
 | 133 | +# For example:  | 
 | 134 | +with torch.no_grad():  | 
 | 135 | +    inputs = feature_prompts["T (degC)"].unsqueeze(0)  | 
 | 136 | +    preds = model(inputs)  | 
 | 137 | +    print("Prediction output shape:", preds.shape)  | 
 | 138 | +```  | 
 | 139 | + | 
 | 140 | +---  | 
 | 141 | + | 
 | 142 | +## Project Structure  | 
 | 143 | + | 
 | 144 | +```text  | 
 | 145 | +└── ltsm-package/  | 
 | 146 | +    ├── datasets  | 
 | 147 | +    │   └── README.md  | 
 | 148 | +    ├── imgs  | 
 | 149 | +    │   ├── ltsm_model.png  | 
 | 150 | +    │   ├── prompt_csv_tsne.png  | 
 | 151 | +    │   └── stat_prompt.png  | 
 | 152 | +    ├── ltsm  | 
 | 153 | +    │   ├── common                  # Base classes   | 
 | 154 | +    │   ├── data_pipeline           # Model lifecycle management and training pipeline  | 
 | 155 | +    │   ├── data_provider           # Dataset construction  | 
 | 156 | +    │   ├── data_reader             # Read input data from various formats (CSV, JSON, etc.)  | 
 | 157 | +    │   ├── evaluate_pipeline       # Evaluation workflow for model performance  | 
 | 158 | +    │   ├── layers                  # Custom neural network components  | 
 | 159 | +    │   ├── models                  # Implementations: LTSM, DLinear, Informer, PatchTST  | 
 | 160 | +    │   ├── prompt_reader           # Prompt generation and formatting  | 
 | 161 | +    │   ├── sk_interface            # Scikit-learn style interface  | 
 | 162 | +    │   └── utils                   # Shared helper functions  | 
 | 163 | +    ├── multi_agents_pipeline       # Multi-agent time series reasoning framework  | 
 | 164 | +    │   ├── Readme.md  | 
 | 165 | +    │   ├── agents                  # Agent definitions: Planner, QA, TS, Reward  | 
 | 166 | +    │   ├── llm-server.py           # Local LLM server interface  | 
 | 167 | +    │   ├── ltsm_inference.py       # Inference script using LTSM pipeline  | 
 | 168 | +    │   ├── main.py                 # Pipeline entry point  | 
 | 169 | +    │   └── model_config.yaml       # Configuration file for models and agents  | 
 | 170 | +    ├── requirements.txt  | 
 | 171 | +    ├── setup.py  | 
 | 172 | +    ├── tests                       # Unit tests for LTSM modules  | 
 | 173 | +    │   ├── common  | 
 | 174 | +    │   ├── data_pipeline  | 
 | 175 | +    │   ├── data_provider  | 
 | 176 | +    │   ├── data_reader  | 
 | 177 | +    │   ├── evaluate_pipeline  | 
 | 178 | +    │   ├── models  | 
 | 179 | +    │   └── test_scripts  | 
 | 180 | +    └── tutorial  | 
 | 181 | +        └── README.md  | 
50 | 182 | ```  | 
51 | 183 | 
 
  | 
52 |  | -## Datasets and Time Series Prompts  | 
53 |  | -Download the datasets  | 
 | 184 | +---  | 
 | 185 | + | 
 | 186 | +## Datasets and Prompts  | 
 | 187 | + | 
 | 188 | +Download datasets:  | 
 | 189 | + | 
54 | 190 | ```bash  | 
55 | 191 | cd datasets  | 
56 |  | -download: https://drive.google.com/drive/folders/1hLFbz0FRxdiDCzgFYtKCOPJYSBVvwW9P  | 
 | 192 | +# Google Drive link:  | 
 | 193 | +https://drive.google.com/drive/folders/1hLFbz0FRxdiDCzgFYtKCOPJYSBVvwW9P  | 
57 | 194 | ```  | 
58 | 195 | 
 
  | 
59 |  | -Download the time series prompts   | 
 | 196 | +Download time series prompts:  | 
 | 197 | + | 
60 | 198 | ```bash  | 
61 |  | -cd prompt_bank/propmt_data_csv  | 
62 |  | -download: https://drive.google.com/drive/folders/1hLFbz0FRxdiDCzgFYtKCOPJYSBVvwW9P  | 
 | 199 | +cd prompt_bank/prompt_data_csv  | 
 | 200 | +# Same Google Drive link applies  | 
63 | 201 | ```  | 
64 | 202 | 
 
  | 
 | 203 | +---  | 
 | 204 | + | 
 | 205 | +## Model Access  | 
 | 206 | + | 
 | 207 | +You can find our trained LTSM models on Hugging Face:  | 
 | 208 | + | 
 | 209 | +➡️ [https://huggingface.co/LSC2204/LTSM-bundle](https://huggingface.co/LSC2204/LTSM-bundle)  | 
 | 210 | + | 
 | 211 | +---  | 
 | 212 | + | 
65 | 213 | ## Cite This Work  | 
66 |  | -If you find this work useful, you may cite this work:  | 
67 |  | -```  | 
68 |  | -@article{ltsm-bundle,  | 
69 |  | -  title={Understanding Different Design Choices in Training Large Time Series Models},  | 
70 |  | -  author={Chuang*, Yu-Neng and Li*, Songchen and Yuan*, Jiayi and Wang*, Guanchu and Lai*, Kwei-Herng and Yu, Leisheng and Ding, Sirui and Chang, Chia-Yuan and Tan, Qiaoyu and Zha, Daochen and Hu, Xia},  | 
71 |  | -  journal={arXiv preprint arXiv:2406.14045},  | 
72 |  | -  year={2024}  | 
 | 214 | + | 
 | 215 | +If you find this work useful, please cite:  | 
 | 216 | + | 
 | 217 | +```bibtex  | 
 | 218 | +@misc{chuang2025ltsmbundletoolboxbenchmarklarge,  | 
 | 219 | +      title={LTSM-Bundle: A Toolbox and Benchmark on Large Language Models for Time Series Forecasting},  | 
 | 220 | +      author={Yu-Neng Chuang and Songchen Li and Jiayi Yuan and Guanchu Wang and Kwei-Herng Lai and Songyuan Sui and Leisheng Yu and Sirui Ding and Chia-Yuan Chang and Qiaoyu Tan and Daochen Zha and Xia Hu},  | 
 | 221 | +      year={2025},  | 
 | 222 | +      eprint={2406.14045},  | 
 | 223 | +      archivePrefix={arXiv},  | 
 | 224 | +      primaryClass={cs.LG},  | 
 | 225 | +      url={https://arxiv.org/abs/2406.14045},  | 
73 | 226 | }  | 
74 | 227 | ```  | 
 | 228 | + | 
 | 229 | +---  | 
 | 230 | + | 
 | 231 | +## License  | 
 | 232 | + | 
 | 233 | +This project is licensed under the MIT License. See the [LICENSE](https://choosealicense.com/licenses/mit/) file for details.  | 
 | 234 | + | 
 | 235 | +---  | 
 | 236 | + | 
 | 237 | +## Acknowledgments  | 
 | 238 | + | 
 | 239 | +We thank all contributors and collaborators involved in the LTSM project. Special thanks to the Data Lab at Rice University and the open-source community for enabling fast prototyping and reproducible research.  | 
 | 240 | + | 
 | 241 | +---  | 
 | 242 | + | 
 | 243 | +<div align="right">  | 
 | 244 | +    <a href="#top">⬆️ Back to Top</a>  | 
 | 245 | +</div>  | 
0 commit comments