SiDModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

Score Identity Distillation (SiD) model for single-step generation via score identity.

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

For Beginners

SiD uses a clever mathematical identity to train a fast model. The pretrained diffusion model tells the student model exactly how its outputs differ from real images, providing a precise training signal. This produces clean single-step images without needing a separate discriminator network.

How It Works

SiD distills a pretrained diffusion model into a single-step generator by exploiting the score identity: the score function of the generator’s output distribution should match the pretrained model’s score. This avoids the need for a discriminator or regression loss, using only the pretrained score function for training.

Reference: Zhou et al., “Score Identity Distillation: Exponentially Fast Distillation of Pretrained Diffusion Models”, ICML 2024

Example

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

Constructors

Constructor Summary
SiDModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) Initializes a new SiD 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()