liveBook · Manning

Language model

As explained in Time Series Forecasting Using Foundation Models

A large language model is a neural-network model trained on large text corpora to perform language understanding and generation tasks.

A large language model is a foundation model for natural-language processing, trained to perform tasks such as question answering, text classification, translation, and text generation. Its core capability is language generation rather than time-series forecasting. section 8.10 section 1.4

For forecasting, convert a numerical sequence into a natural-language prompt, ask for the next values, and parse the generated string back into predictions. This approach treats forecasting as next-token-like prediction, but requires careful prompt construction and output processing. section 8.0 section 8.10

Practical considerations shape whether an LLM is appropriate for forecasting:

  • Use prompting when a natural-language interface is required and robust prompts can be constructed. section 8.0
  • Experiment with zero-shot, few-shot, and chain-of-thought prompts; few-shot and chain-of-thought prompting usually produce the best results. section 8.10 section 8.9
  • Expect extra preprocessing and extraction code, substantial computational requirements for local deployment, and potentially poor forecasting performance. section 8.10 section 8.9

Prompt-based forecasting

Flan-T5 and Llama-3.2-3b-instruct can receive programmatically constructed prompts containing an input series and return a string whose values are extracted as forecasts. They can also be used locally or through API calls. section 8.0 section 8.10

Table 8.3 Pros and cons of each foundation forecasting model

Model

Pros

Cons

When to use

TimeGPT

Easy and fast to use

Comes with many native functions

Works on any device, regardless of hardware

Free plan

Paid product for a certain usage

Model may not be available if the server is down.

Forecasting on long and short horizons with exogenous features.

You need to fine-tune but do not have the local resources.

Lag-Llama

Open source model

Free to use

Awkward to use because we must clone the repository

Speed of inference depends on our hardware.

Quick proof of concept

Ideal for research-oriented projects

Chronos

Open source model

Free to use

Can be installed as a Python package

Speed and accuracy depend on our hardware.

Fine-tuning requires cloning the repository.

We must define some functions manually.

Forecasting on horizons shorter than 64 time steps

Forecasting series without strong trends

TimesFM

Open source model

Free to use

Can be installed as a Python package

Supports exogenous features

Only the largest model is available.

Restrictive requirements for use (16 GB of RAM, Linux-based system to install dependencies)

Knowledge of JAX is required for fine-tuning.

Cannot perform anomaly detection because it is a deterministic model

Ideal for deterministic forecasting in which prediction intervals are not required

You want to feed a long input series.

Moirai

Open source model

Free to use

Supports exogenous features

Can be installed as a Python package

Speed and accuracy depend on the hardware.

We must define helper functions when not working entirely with GluonTS.

You have exogenous features.

Forecasting on horizons shorter than 256 time steps

Large language models (Flan-T5 and Llama-3.2)

Possible to use free LLMs

Interacting through natural language feels intuitive,

Not built to handle time-series data

Requires lengthy code to preprocess the input and extract the values from the output

Requires a lot of computation power for local setups

You already have access to an LLM.

You need a natural language interface for forecasting.

You know how to develop prompts and safeguards for edge cases.

Compare LLM-based forecasting with purpose-built foundation forecasting models by hardware needs, deployment, speed, and suitable use cases. section 8.9

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Defines language-model capabilities and details prompt construction and output parsing, but stops short of making LLMs forecasting-specific.
Examples
Uses Flan-T5, Llama-3.2-3b-instruct, natural-language prompts, generated strings, and extracted forecast values.
What it assumes
Assumes basic familiarity with LLMs and prompt engineering, while introducing their characteristics before applying them to forecasting.
What you can do after
Apply it via prompting to forecast time series, while evaluating whether preprocessing, computation, and accuracy trade-offs justify its use.
How it connects
Connects foundation models, prompt engineering, time-series forecasting, zero-shot learning, few-shot learning, and chain-of-thought prompting.

Also explained in

Compare how 67 books explain language model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Time Series Forecasting Using Foundation Models. The section links point to the parts of the book it draws on.