FlowState<T>

Models & Types · AiDotNet.Finance.Forecasting.Foundation

FlowState — IBM’s SSM-based Time Series Foundation Model (9.1M parameters).

Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → ForecastingModelBase<T> → TimeSeriesFoundationModelBase<T> → FlowState<T>

For Beginners

FlowState is a compact forecasting model from IBM that punches well above its weight. With only 9.1 million parameters (tiny by modern standards), it outperforms models 20 times its size. It uses state-space models, which process data like a conveyor belt rather than looking at everything at once, making it very efficient with long sequences of data like years of daily stock prices.

How It Works

FlowState is IBM’s State-Space Model based time series foundation model. Despite having only 9.1M parameters (smallest in GIFT-Eval top 10), it outperforms models 20x its size and generalizes to unseen timescales. It uses structured state spaces for linear-time processing of long sequences.

Reference: IBM Research, “SSM Time Series Model”, 2025.

Example

// Create a FlowState SSM-based foundation model (IBM, only 9.1M params)
// Uses structured state spaces for linear-time processing of long sequences
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.Regression,
    inputHeight: 512, inputWidth: 1, inputDepth: 1, outputSize: 24);
            
// Training mode with state-space model layers
var model = new FlowState<double>(architecture);
            
// ONNX inference mode with pre-trained model
var onnxModel = new FlowState<double>(architecture, "flowstate.onnx");

Constructors

Constructor Summary
FlowState(NeuralNetworkArchitecture<T> architecture, FlowStateOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) Creates a FlowState model in native mode.
FlowState(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, FlowStateOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) Creates a FlowState model using a pretrained ONNX model.

Properties

Property Summary
FoundationModelSize ModelSize { get; }
bool IsChannelIndependent { get; }
bool SupportsTraining { get; }
bool UseNativeMode { get; }
int MaxContextLength { get; }
int MaxPredictionHorizon { get; }
int NumFeatures { get; }
int PatchSize { get; }
int PredictionHorizon { get; }
int SequenceLength { get; }
int Stride { get; }

Methods

Method Summary
Dictionary<string, T> Evaluate(Tensor<T> predictions, Tensor<T> actuals)
Dictionary<string, T> GetFinancialMetrics()
Dictionary<string, Tensor<T>> GetNamedLayerActivations(Tensor<T> input)
ModelMetadata<T> GetModelMetadata()
Tensor<T> ApplyInstanceNormalization(Tensor<T> input)
Tensor<T> AutoregressiveForecast(Tensor<T> input, int steps)