MultistepLCModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

Multistep Latent Consistency Model (MLCM) for high-quality few-step generation.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → MultistepLCModel<T>

For Beginners

LCM generates images in 2-4 steps. MLCM improves on this by training the model to be consistent across different numbers of steps — meaning it produces good results whether you use 2, 4, or 8 steps. This flexibility lets you choose the best speed/quality tradeoff for your use case.

How It Works

MLCM extends Latent Consistency Models to support multiple distillation targets per training step, improving generation quality at 2-8 steps. Uses a multistep consistency loss that enforces the model to be self-consistent across multiple denoising trajectories simultaneously.

Reference: Based on Latent Consistency Models (Luo et al., 2023) with multistep extensions

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 4 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 4, 64, 64 });
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 MultistepLCModel<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
MultistepLCModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) Initializes a new Multistep Latent Consistency Model.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> VAE { get; }
int LatentChannels { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()