TEST<T>

Models & Types · AiDotNet.Finance.Forecasting.Foundation

TEST — Text Prototype Aligned Embedding to Activate LLM’s Ability for Time Series.

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

For Beginners

TEST bridges the gap between language models and time series by creating text descriptions of temporal patterns (like “rising trend with weekly seasonality”) and teaching the model to align numerical patterns with these descriptions. This lets a language model understand time series without converting numbers to text, combining the best of both worlds.

How It Works

TEST generates text-prototype-aligned embeddings for time series by leveraging pretrained language model knowledge. It translates seasonal/trend patterns into text descriptions and aligns time series embeddings to these text prototypes via contrastive learning.

Reference: Sun et al., “TEST: Text Prototype Aligned Embedding to Activate LLM’s Ability for Time Series”, 2024.

Example

// Create a TEST model that aligns time series embeddings with text prototypes
// Bridges language models and time series via contrastive learning on pattern descriptions
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.Regression,
    inputHeight: 512, inputWidth: 1, inputDepth: 1, outputSize: 24);
            
// Training mode with text-prototype alignment
var model = new TEST<double>(architecture);
            
// ONNX inference mode with pre-trained model
var onnxModel = new TEST<double>(architecture, "test_model.onnx");

Constructors

Constructor Summary
TEST(NeuralNetworkArchitecture<T> architecture, TESTOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) Creates a TEST model in native mode for training or fine-tuning.
TEST(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, TESTOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) Creates a TEST 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()
ModelMetadata<T> GetModelMetadata()
Tensor<T> ApplyInstanceNormalization(Tensor<T> input)
Tensor<T> AutoregressiveForecast(Tensor<T> input, int steps)