Granite Time Series
The granite-timeseries-ttm-v1 model is a compact pre-trained model for Multivariate Time-Series Forecasting, open-sourced by IBM Research. With less than 1 Million parameters, it introduces the notion of the first-ever tiny pre-trained models for Time-Series Forecasting.
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:
- 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.
- Load the pretrained granite model
- 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)