Skip to main contentIBM Granite
granite-timeseries-ttm-v1

Granite Time Series

Try Granite Time Series
Coming Soon

For time series foundation models, the prompt does not consist of free-form text, instead we pass context windows of time series data, as well as configure the model based on metadata about the time series itself. These include things like the type of column (target, categorical, control, etc.) or the frequency or resolution of the data (minute, hourly, etc.).

Zero-shot inference

The basic steps to conduct zero-shot inference with Granite-TTM, are the following:

  1. Load and prepare data using the time series preprocessor: the time series preprocessor is responsible for scaling data, encoding categorical values, and provides other utilities that make configuring the pre-trained model easier.
  2. Load the pretrained granite model
  3. Generate forecasts using the time series forecasting pipeline

For the example code-snippets below, we assume that a dataset is available with a timestamp column (“date”), and two target value columns (“value1”, “value2”).

Prerequisites

Please make sure your python environment is properly set up. The code snippets below are illustrative examples of how various components work with our Granite-TimeSeries models, and require the installation of the Granite TSFM library. Please see the setup instructions.

Load data

Pandas dataframes are required in the preprocessing and forecasting pipeline components. We simply read the csv into a pandas dataframe, making sure to format the timestamp column properly.

data = pd.read_csv(
dataset_path,
parse_dates=["date"],
)

Prepare data

In the zero-shot case, we can only handle datasets with id columns and one or more target columns. Advanced use cases involving exogenous or categorical features are not yet supported.

tsp = TimeSeriesPreprocessor(
id_columns=[],
timestamp_column="date"
target_columns=["value1", "value2"],
prediction_length=96,

Load the pretrained Granite timeseries model

Here we load the model using from_pretrained but pass some extra configuration.

model = TinyTimeMixerForPrediction.from_pretrained("ibm-granite/granite-timeseries-ttm-v1",
num_input_channels=tsp.num_input_channels)

Generate forecasts

First we instantiate the time series pipeline, then use it to make forecasts:

pipeline = TimeSeriesForecastingPipeline(
model=model,
feature_extractor=tsp)
forecasts = pipeline(data)