KolorsModel<T>
Models & Types · AiDotNet.Diffusion.TextToImage
Kolors model — ChatGLM3-powered bilingual text-to-image model by Kwai.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → KolorsModel<T>
For Beginners
Kolors is like SDXL but with Chinese language understanding:
Key characteristics:
- ChatGLM3-6B text encoder: strong Chinese + English understanding
- SDXL-like U-Net backbone: proven architecture for quality
- 4096-dim cross-attention from ChatGLM3 embeddings
- Native 1024x1024 resolution
- Open-source with Apache 2.0 license
How Kolors works:
- Text goes through ChatGLM3-6B (6B parameter language model)
- 4096-dim embeddings provide rich text understanding
- SDXL-like U-Net denoises with cross-attention to embeddings
- VAE decodes to final image
Use Kolors when you need:
- Chinese text-to-image generation
- Open-source bilingual model
- SDXL-quality with multilingual support
How It Works
Kolors is Kwai’s text-to-image model that uses ChatGLM3-6B as the text encoder, providing strong bilingual (Chinese-English) text understanding. It builds on the SDXL U-Net architecture with ChatGLM3’s 4096-dim embeddings for cross-attention.
Technical specifications:
- Architecture: SDXL U-Net with ChatGLM3-6B text encoder
- Text encoder: ChatGLM3-6B (4096-dim, 65024 vocab)
- U-Net: ~2.6B parameters
- Resolution: 1024x1024
- Latent space: 4 channels, 8x downsampling
- Guidance scale: 5.0-7.5 recommended
Reference: Kwai, “Kolors: Effective Training of Diffusion Model for Photorealistic Text-to-Image Synthesis”, 2024
Example
var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 25 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 4, 128, 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 KolorsModel<float>(options: options))
.Build(trainX, trainY);
var generated = result.Predict(noise);
Constructors
| Constructor | Summary |
|---|---|
KolorsModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> unet, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) |
Initializes a new instance of KolorsModel with full customization support. |
Properties
| Property | Summary |
|---|---|
IConditioningModule<T> Conditioner { get; } |
|
INoisePredictor<T> NoisePredictor { get; } |
|
IVAEModel<T> VAE { get; } |
|
int LatentChannels { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> GenerateFromText(string prompt, string negativePrompt, int width, int height, int numInferenceSteps, double? guidanceScale, int? seed) |
Fields
| Field | Summary |
|---|---|
int DefaultHeight |
|
int DefaultWidth |