XLSTMLanguageModel<T>

Models & Types · AiDotNet.NeuralNetworks

Implements a full xLSTM language model: token embedding + N ExtendedLSTMLayer blocks + RMS normalization + LM head.

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → TokenLanguageModelLayoutBase<T> → XLSTMLanguageModel<T>

For Beginners

xLSTM is a modern version of the classic LSTM that uses stronger gates and richer memory to achieve quality competitive with Transformers and Mamba while maintaining linear-time inference.

How It Works

xLSTM (Extended LSTM) modernizes the classic LSTM architecture with exponential gating, new memory structures, and residual block stacking to achieve competitive language modeling performance.

Reference: Beck et al., “xLSTM: Extended Long Short-Term Memory”, 2024.

Example

var architecture = new NeuralNetworkArchitecture<float>(inputFeatures: 8, outputSize: 4);
var tokens = Tensor<float>.CreateRandom(new[] { 1, 128 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new XLSTMLanguageModel<float>(architecture))
    .Build(trainX, trainY);
var logits = result.Predict(tokens);

Constructors

Constructor Summary
XLSTMLanguageModel(NeuralNetworkArchitecture<T> architecture, XLSTMOptions options, ILossFunction<T> lossFunction, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)

Properties

Property Summary
bool SupportsTraining { get; }
int ModelDimension { get; } Gets the model dimension (d_model).
int NumLayers { get; } Gets the number of xLSTM blocks.
int VocabSize { get; } Gets the vocabulary size.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()