HunyuanDiTModel<T>
Models & Types · AiDotNet.Diffusion.TextToImage
Hunyuan-DiT model — bilingual (Chinese-English) DiT text-to-image model by Tencent.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → HunyuanDiTModel<T>
For Beginners
Hunyuan-DiT generates images from Chinese or English prompts:
Key characteristics:
- Bilingual: understands both Chinese and English prompts natively
- DiT backbone: transformer-based denoiser (1.5B parameters)
- Dual text encoders: CLIP-L/14 + mT5-XL for multilingual support
- Multi-resolution training with aspect ratio bucketing
- Human preference alignment via RLHF-like training
How Hunyuan-DiT works:
- Text goes through CLIP (visual) + mT5 (multilingual) encoders
- DiT transformer denoises with cross-attention to both embeddings
- Multi-resolution support through positional embedding interpolation
- VAE decoder produces final image
Use Hunyuan-DiT when you need:
- Chinese text-to-image generation
- Bilingual applications
- Open-source multilingual alternative
How It Works
Hunyuan-DiT is Tencent’s bilingual text-to-image model that uses a DiT transformer backbone with dual text encoders (CLIP + multilingual T5) for both Chinese and English prompt understanding.
Technical specifications:
- Architecture: DiT-XL with dual text conditioning
- Parameters: ~1.5B (DiT backbone)
- Text encoders: CLIP ViT-L/14 (768-dim) + mT5-XL (2048-dim)
- Native resolution: 1024x1024
- Latent space: 4 channels, 8x downsampling
- Guidance scale: 6.0 recommended
Reference: Li et al., “Hunyuan-DiT: A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding”, 2024
Example
var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 30 };
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 HunyuanDiTModel<float>(options: options))
.Build(trainX, trainY);
var generated = result.Predict(noise);
Constructors
| Constructor | Summary |
|---|---|
HunyuanDiTModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, DiTNoisePredictor<T> dit, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) |
Initializes a new instance of HunyuanDiTModel 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 |