GithubHelp home page GithubHelp logo

llmtime's Introduction

Large Language Models Are Zero Shot Time Series Forecasters

This repository contains the code for the paper Large Language Models Are Zero Shot Time Series Forecasters by Nate Gruver, Marc Finzi, Shikai Qiu and Andrew Gordon Wilson (NeurIPS 2023).

Image

We propose LLMTime, a method for zero-shot time series forecasting with large language models (LLMs) by encoding numbers as text and sampling possible extrapolations as text completions. LLMTime can outperform many popular timeseries methods without any training on the target dataset (i.e. zero shot). The performance of LLMTime also scales with the power of the underlying base model. However, models that undergo alignment (e.g. RLHF) do not follow the scaling trend. For example, GPT-4 demonstrates inferior performance to GPT-3.

๐Ÿ›  Installation

Run the following command to install all dependencies in a conda environment named llmtime. Change the cuda version for torch if you don't have cuda 11.8.

sh install.sh

After installation, activate the environment with

conda activate llmtime

If you prefer not using conda, you can also install the dependencies listed in install.sh manually.

Finally, add your openai api key to ~/.bashrc with

echo "export OPENAI_API_KEY=<your key>" >> ~/.bashrc

๐Ÿš€ Trying out LLMTime

Want a quick taste of the power of LLMTime? Run the quick demo in the demo.ipynb notebook. No GPUs required!

๐Ÿค– Plugging in other LLMs

We currently support GPT-3, GPT-3.5, GPT-4, and LLaMA 2. It's easy to plug in other LLMs by simply specifying how to generate text completions from them in models/llms.py.

๐Ÿ’ก Tips

Here are some tips for using LLMTime:

  • Performance is not too sentitive to the data scaling hyperparameters alpha, beta, basic. A good default is alpha=0.95, beta=0.3, basic=False. For data exhibiting symmetry around 0 (e.g. a sine wave), we recommend setting basic=True to avoid shifting the data.
  • The recently released gpt-3.5-turbo-instruct seems to require a lower temperature (e.g. 0.3) than other models, and tends to not outperform text-davinci-003 from our limited experiments.
  • Tuning hyperparameters based on validation likelihoods, as done by get_autotuned_predictions_data, will often yield better test likelihoods, but won't necessarily yield better samples.

๐Ÿ“Š Replicating experiments in paper

Run the following commands to replicate the experiments in the paper. The outputs will be saved in ./outputs/. You can use visualize.ipynb to visualize the results. We also provide precomputed outputs used in the paper in ./precomputed_outputs/.

Darts (Section 4)

python -m experiments.run_darts

Monash (Section 4)

First download and process the dataset

python -m data.monash

Then run the experiment

python -m experiments.run_monash

Synthetic (Section 5)

python -m experiments.run_synthetic

Missing values (Section 6)

python -m experiments.run_missing

Memorization (Appendix B)

python -m experiments.run_memorization

Citation

Please cite our work as:

@inproceedings{gruver2023llmtime,
    title={{Large Language Models Are Zero Shot Time Series Forecasters}},
    author={Nate Gruver, Marc Finzi, Shikai Qiu and Andrew Gordon Wilson},
    booktitle={Advances in Neural Information Processing Systems},
    year={2023}
}

llmtime's People

Contributors

ngruver avatar shikaiqiu avatar andrewgordonwilson avatar

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.