Giter Site home page Giter Site logo

allm4ts's Introduction

aLLM4TS

This repository contains the implementation of the ICML2024 paper "Multi-Patch Prediction: Adapting LLMs for Time Series Representation Learning"

Yuxuan Bian12, Xuan Ju1, Jiangtong Li1, Zhijian Xu1, Dawei Cheng2*, Qiang Xu1*
1The Chinese University of Hong Kong 2Tongji University *Corresponding Author

๐Ÿ“– Table of Contents

๐Ÿ“– Abstract

In this study, we present $\text{aL\small{LM}4T\small{S}}$, an innovative framework that adapts Large Language Models (LLMs) for time-series representation learning. Central to our approach is that we reconceive time-series forecasting as a self-supervised, multi-patch prediction task, which, compared to traditional contrastive learning or mask-and-reconstruction methods, captures temporal dynamics in patch representations more effectively. Our strategy encompasses two-stage training: (i). a causal continual pre-training phase on various time-series datasets, anchored on next patch prediction, effectively syncing LLM capabilities with the intricacies of time-series data; (ii). fine-tuning for multi-patch prediction in the targeted time-series context. A distinctive element of our framework is the patch-wise decoding layer, which departs from previous methods reliant on sequence-level decoding. Such a design directly transposes individual patches into temporal sequences, thereby significantly bolstering the model's proficiency in mastering temporal patch-based representations. $\text{aL\small{LM}4T\small{S}}$ demonstrates superior performance in several downstream tasks, proving its effectiveness in deriving temporal representations with enhanced transferability and marking a pivotal advancement in the adaptation of LLMs for time-series analysis.

๐Ÿ” System Overview

๐ŸŒŸ Two-stage Self-supervised Forecasting-based Training: Central to our approach is that we reconceive time-series forecasting as a self-supervised, multi-patch prediction task, which, compared to traditional mask-and-reconstruction methods, captures temporal dynamics in patch representations more effectively. two-stage

๐ŸŒŸ Patch-wise Decoding: A distinctive element of our framework is the patch-wise decoding layer, which departs from previous methods reliant on sequence-level decoding. Such a design directly transposes individual patches into temporal sequences, thereby significantly bolstering the model's proficiency in mastering temporal patch-based representations.

decoder

๐Ÿš€ Quick Start

Requirements

  • accelerate==0.21.0
  • bitsandbytes==0.41.1
  • cmake==3.24.1.1
  • Cython==0.29.34
  • datasets==2.14.3
  • deepspeed==0.9.3
  • einops==0.6.1
  • numpy==1.22.2
  • safetensors==0.3.3
  • scikit-learn==1.3.0
  • sentencepiece==0.1.99
  • sktime==0.25.0
  • thop==0.1.1.post2209072238
  • torch==2.0.0
  • torchinfo==1.8.0
  • torchsummary==1.5.1
  • transformers==4.34.0

To create the environment and install all dependencies:

conda create -n allm4ts python=3.10 -y
conda activate allm4ts
pip install -r requirements.txt

Datasets

You can access the well pre-processed datasets from [Google Drive], then place the downloaded contents under ./dataset

Quick Demos

  1. Download datasets and place them under ./dataset
  2. Conduct the stage 1: Casual Next-patch Continual Pre-training. We provide a experiment script for demonstration purpose under the folder ./scripts. For example, you can conduct stage 1 continual pre-training by:
bash ./scripts/pretrain/all_s16.sh
  1. Tune the model in different time-series analysis tasks. We provide many experiment scripts for demonstration purpose under the folder ./scripts. For example, you can evaluate the long-term forecasting or the anomaly detection by:
bash ./scripts/long-term-forecasting/all.sh
bash ./scripts/anomaly-detection/all.sh

๐Ÿค๐Ÿผ Citation

If you find the code is useful in your research, please cite us:

@article{bian2024multi,
  title={Multi-Patch Prediction: Adapting LLMs for Time Series Representation Learning},
  author={Bian, Yuxuan and Ju, Xuan and Li, Jiangtong and Xu, Zhijian and Cheng, Dawei and Xu, Qiang},
  journal={International Conference on Machine Learning ({ICML})},
  year={2024}
}

๐Ÿ’– Acknowledgement

We appreciate the following github repo very much for the valuable code base and datasets: DLinear, PatchTST, Time-Series-Library, and OneFitsAll. Thanks to all contributors!

allm4ts's People

Contributors

yxbian23 avatar

Stargazers

 avatar 123 avatar  avatar  avatar  avatar Qingren avatar  avatar  avatar  avatar  avatar  avatar  avatar Peng Chen avatar  avatar  avatar  avatar Yang Yu avatar  avatar  avatar Anonymous submitter avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

allm4ts's Issues

ValueError: could not convert string to float: '380,710,659,898,477'

Hi, thank you for your excellent work. I encountered the following problem while following your work, which I couldn't solve. If you could help me resolve it, I would be very grateful.

bash ./scripts/pretrain/all_s16.sh

Traceback (most recent call last):
File "/root/autodl-tmp/aLLM4TS/run_LLM4TS.py", line 173, in
exp.train(setting)
File "/root/autodl-tmp/aLLM4TS/exp/exp_LLM4TS.py", line 140, in train
train_data, train_loader = self._get_data(flag='train')
File "/root/autodl-tmp/aLLM4TS/exp/exp_LLM4TS.py", line 60, in _get_data
data_set, data_loader = data_provider(self.args, flag)
File "/root/autodl-tmp/aLLM4TS/data_provider/data_factory.py", line 101, in data_provider
data_set = Data(
File "/root/autodl-tmp/aLLM4TS/data_provider/data_loader.py", line 47, in init
self.read_data()
File "/root/autodl-tmp/aLLM4TS/data_provider/data_loader.py", line 88, in read_data
self.scaler.fit(train_data)
File "/root/miniconda3/envs/mamba_lang/lib/python3.10/site-packages/sklearn/preprocessing/_data.py", line 837, in fit
return self.partial_fit(X, y, sample_weight)
File "/root/miniconda3/envs/mamba_lang/lib/python3.10/site-packages/sklearn/base.py", line 1151, in wrapper
return fit_method(estimator, *args, **kwargs)
File "/root/miniconda3/envs/mamba_lang/lib/python3.10/site-packages/sklearn/preprocessing/_data.py", line 873, in partial_fit
X = self._validate_data(
File "/root/miniconda3/envs/mamba_lang/lib/python3.10/site-packages/sklearn/base.py", line 604, in _validate_data
out = check_array(X, input_name="X", **check_params)
File "/root/miniconda3/envs/mamba_lang/lib/python3.10/site-packages/sklearn/utils/validation.py", line 917, in check_array
array = _asarray_with_order(array, order=order, dtype=dtype, xp=xp)
File "/root/miniconda3/envs/mamba_lang/lib/python3.10/site-packages/sklearn/utils/_array_api.py", line 380, in _asarray_with_order
array = numpy.asarray(array, order=order, dtype=dtype)
ValueError: could not convert string to float: '380,710,659,898,477'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.