|  | 
|  | 1 | +<!--Copyright 2025 The HuggingFace Team. All rights reserved. | 
|  | 2 | +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | 
|  | 3 | +the License. You may obtain a copy of the License at | 
|  | 4 | +http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 5 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | 
|  | 6 | +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | 
|  | 7 | +specific language governing permissions and limitations under the License. | 
|  | 8 | +--> | 
|  | 9 | + | 
|  | 10 | +# Kandinsky 5.0 | 
|  | 11 | + | 
|  | 12 | +Kandinsky 5.0 is created by the Kandinsky team: Alexey Letunovskiy, Maria Kovaleva, Ivan Kirillov, Lev Novitskiy, Denis Koposov, Dmitrii Mikhailov, Anna Averchenkova, Andrey Shutkin, Julia Agafonova, Olga Kim, Anastasiia Kargapoltseva, Nikita Kiselev, Anna Dmitrienko,  Anastasia Maltseva, Kirill Chernyshev, Ilia Vasiliev, Viacheslav Vasilev, Vladimir Polovnikov, Yury Kolabushin, Alexander Belykh, Mikhail Mamaev, Anastasia Aliaskina, Tatiana Nikulina, Polina Gavrilova, Vladimir Arkhipkin, Vladimir Korviakov, Nikolai Gerasimenko, Denis Parkhomenko, Denis Dimitrov | 
|  | 13 | + | 
|  | 14 | + | 
|  | 15 | +Kandinsky 5.0 is a family of diffusion models for Video & Image generation. Kandinsky 5.0 T2V Lite is a lightweight video generation model (2B parameters) that ranks #1 among open-source models in its class. It outperforms larger models and offers the best understanding of Russian concepts in the open-source ecosystem. | 
|  | 16 | + | 
|  | 17 | +The model introduces several key innovations: | 
|  | 18 | +- **Latent diffusion pipeline** with **Flow Matching** for improved training stability | 
|  | 19 | +- **Diffusion Transformer (DiT)** as the main generative backbone with cross-attention to text embeddings | 
|  | 20 | +- Dual text encoding using **Qwen2.5-VL** and **CLIP** for comprehensive text understanding | 
|  | 21 | +- **HunyuanVideo 3D VAE** for efficient video encoding and decoding | 
|  | 22 | +- **Sparse attention mechanisms** (NABLA) for efficient long-sequence processing | 
|  | 23 | + | 
|  | 24 | +The original codebase can be found at [ai-forever/Kandinsky-5](https://github.com/ai-forever/Kandinsky-5). | 
|  | 25 | + | 
|  | 26 | +> [!TIP] | 
|  | 27 | +> Check out the [AI Forever](https://huggingface.co/ai-forever) organization on the Hub for the official model checkpoints for text-to-video generation, including pretrained, SFT, no-CFG, and distilled variants. | 
|  | 28 | +
 | 
|  | 29 | +## Available Models | 
|  | 30 | + | 
|  | 31 | +Kandinsky 5.0 T2V Lite comes in several variants optimized for different use cases: | 
|  | 32 | + | 
|  | 33 | +| model_id | Description | Use Cases | | 
|  | 34 | +|------------|-------------|-----------| | 
|  | 35 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-sft-5s-Diffusers** | 5 second Supervised Fine-Tuned model | Highest generation quality | | 
|  | 36 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-sft-10s-Diffusers** | 10 second Supervised Fine-Tuned model | Highest generation quality | | 
|  | 37 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-nocfg-5s-Diffusers** | 5 second Classifier-Free Guidance distilled | 2× faster inference | | 
|  | 38 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-nocfg-10s-Diffusers** | 10 second Classifier-Free Guidance distilled | 2× faster inference | | 
|  | 39 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-distilled16steps-5s-Diffusers** | 5 second Diffusion distilled to 16 steps | 6× faster inference, minimal quality loss | | 
|  | 40 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-distilled16steps-10s-Diffusers** | 10 second Diffusion distilled to 16 steps | 6× faster inference, minimal quality loss | | 
|  | 41 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-pretrain-5s-Diffusers** | 5 second Base pretrained model | Research and fine-tuning | | 
|  | 42 | +| **ai-forever/Kandinsky-5.0-T2V-Lite-pretrain-10s-Diffusers** | 10 second Base pretrained model | Research and fine-tuning | | 
|  | 43 | + | 
|  | 44 | +All models are available in 5-second and 10-second video generation versions. | 
|  | 45 | + | 
|  | 46 | +## Kandinsky5T2VPipeline | 
|  | 47 | + | 
|  | 48 | +[[autodoc]] Kandinsky5T2VPipeline | 
|  | 49 | +    - all | 
|  | 50 | +    - __call__ | 
|  | 51 | + | 
|  | 52 | +## Usage Examples | 
|  | 53 | + | 
|  | 54 | +### Basic Text-to-Video Generation | 
|  | 55 | + | 
|  | 56 | +```python | 
|  | 57 | +import torch | 
|  | 58 | +from diffusers import Kandinsky5T2VPipeline | 
|  | 59 | +from diffusers.utils import export_to_video | 
|  | 60 | + | 
|  | 61 | +# Load the pipeline | 
|  | 62 | +model_id = "ai-forever/Kandinsky-5.0-T2V-Lite-sft-5s-Diffusers" | 
|  | 63 | +pipe = Kandinsky5T2VPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) | 
|  | 64 | +pipe = pipe.to("cuda") | 
|  | 65 | + | 
|  | 66 | +# Generate video | 
|  | 67 | +prompt = "A cat and a dog baking a cake together in a kitchen." | 
|  | 68 | +negative_prompt = "Static, 2D cartoon, cartoon, 2d animation, paintings, images, worst quality, low quality, ugly, deformed, walking backwards" | 
|  | 69 | + | 
|  | 70 | +output = pipe( | 
|  | 71 | +    prompt=prompt, | 
|  | 72 | +    negative_prompt=negative_prompt, | 
|  | 73 | +    height=512, | 
|  | 74 | +    width=768, | 
|  | 75 | +    num_frames=121,  # ~5 seconds at 24fps | 
|  | 76 | +    num_inference_steps=50, | 
|  | 77 | +    guidance_scale=5.0, | 
|  | 78 | +).frames[0] | 
|  | 79 | + | 
|  | 80 | +export_to_video(output, "output.mp4", fps=24, quality=9) | 
|  | 81 | +``` | 
|  | 82 | + | 
|  | 83 | +### 10 second Models | 
|  | 84 | +**⚠️ Warning!** all 10 second models should be used with Flex attention and max-autotune-no-cudagraphs compilation: | 
|  | 85 | + | 
|  | 86 | +```python | 
|  | 87 | +pipe = Kandinsky5T2VPipeline.from_pretrained( | 
|  | 88 | +    "ai-forever/Kandinsky-5.0-T2V-Lite-sft-10s-Diffusers",  | 
|  | 89 | +    torch_dtype=torch.bfloat16 | 
|  | 90 | +) | 
|  | 91 | +pipe = pipe.to("cuda") | 
|  | 92 | + | 
|  | 93 | +pipe.transformer.set_attention_backend( | 
|  | 94 | +    "flex" | 
|  | 95 | +)                                       # <--- Set attention backend to Flex | 
|  | 96 | +pipe.transformer.compile( | 
|  | 97 | +    mode="max-autotune-no-cudagraphs",  | 
|  | 98 | +    dynamic=True | 
|  | 99 | +)                                       # <--- Compile with max-autotune-no-cudagraphs | 
|  | 100 | + | 
|  | 101 | +prompt = "A cat and a dog baking a cake together in a kitchen." | 
|  | 102 | +negative_prompt = "Static, 2D cartoon, cartoon, 2d animation, paintings, images, worst quality, low quality, ugly, deformed, walking backwards" | 
|  | 103 | + | 
|  | 104 | +output = pipe( | 
|  | 105 | +    prompt=prompt, | 
|  | 106 | +    negative_prompt=negative_prompt, | 
|  | 107 | +    height=512, | 
|  | 108 | +    width=768, | 
|  | 109 | +    num_frames=241, | 
|  | 110 | +    num_inference_steps=50, | 
|  | 111 | +    guidance_scale=5.0, | 
|  | 112 | +).frames[0] | 
|  | 113 | + | 
|  | 114 | +export_to_video(output, "output.mp4", fps=24, quality=9) | 
|  | 115 | +``` | 
|  | 116 | + | 
|  | 117 | +### Diffusion Distilled model | 
|  | 118 | +**⚠️ Warning!** all nocfg and diffusion distilled models should be inferred without CFG (```guidance_scale=1.0```): | 
|  | 119 | + | 
|  | 120 | +```python | 
|  | 121 | +model_id = "ai-forever/Kandinsky-5.0-T2V-Lite-distilled16steps-5s-Diffusers" | 
|  | 122 | +pipe = Kandinsky5T2VPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) | 
|  | 123 | +pipe = pipe.to("cuda") | 
|  | 124 | + | 
|  | 125 | +output = pipe( | 
|  | 126 | +    prompt="A beautiful sunset over mountains", | 
|  | 127 | +    num_inference_steps=16,  # <--- Model is distilled in 16 steps | 
|  | 128 | +    guidance_scale=1.0,      # <--- no CFG | 
|  | 129 | +).frames[0] | 
|  | 130 | + | 
|  | 131 | +export_to_video(output, "output.mp4", fps=24, quality=9) | 
|  | 132 | +``` | 
|  | 133 | + | 
|  | 134 | + | 
|  | 135 | +## Citation | 
|  | 136 | +```bibtex | 
|  | 137 | +@misc{kandinsky2025, | 
|  | 138 | +    author = {Alexey Letunovskiy and Maria Kovaleva and Ivan Kirillov and Lev Novitskiy and Denis Koposov and | 
|  | 139 | +              Dmitrii Mikhailov and Anna Averchenkova and Andrey Shutkin and Julia Agafonova and Olga Kim and | 
|  | 140 | +              Anastasiia Kargapoltseva and Nikita Kiselev and Vladimir Arkhipkin and Vladimir Korviakov and | 
|  | 141 | +              Nikolai Gerasimenko and Denis Parkhomenko and Anna Dmitrienko and Anastasia Maltseva and | 
|  | 142 | +              Kirill Chernyshev and Ilia Vasiliev and Viacheslav Vasilev and Vladimir Polovnikov and | 
|  | 143 | +              Yury Kolabushin and Alexander Belykh and Mikhail Mamaev and Anastasia Aliaskina and | 
|  | 144 | +              Tatiana Nikulina and Polina Gavrilova and Denis Dimitrov}, | 
|  | 145 | +    title = {Kandinsky 5.0: A family of diffusion models for Video & Image generation}, | 
|  | 146 | +    howpublished = {\url{https://github.com/ai-forever/Kandinsky-5}}, | 
|  | 147 | +    year = 2025 | 
|  | 148 | +} | 
|  | 149 | +``` | 
0 commit comments