Sure! Let's illustrate the specific pipeline of VideoDiT using mathematical equations in LaTeX.
1. Video Data Representation
Let’s begin with the video data ( v ) from the video space ( \mathcal{V} ). Each video ( v ) consists of a sequence of frames representing dynamic content over time.
2. Variational Autoencoder (VAE)
The VAE compresses the high-dimensional video data ( v ) into a lower-dimensional latent representation ( z ) in the latent space ( \mathcal{Z} ).
-
Encoding Step:
The encoder ( E_V ) maps the video ( v ) to the latent representation ( z ):
[
z = E_V(v)
]
-
Decoding Step:
The decoder ( D_V ) reconstructs the video ( \hat{v} ) from the latent representation ( z ):
[
\hat{v} = D_V(z)
]
-
VAE Loss Function:
The VAE is trained to minimize the reconstruction loss along with a regularization term (e.g., Kullback–Leibler divergence):
[
L_{\text{VAE}} = \mathbb{E}{v \sim p{\text{data}}(v)} \left[ | v - D_V(E_V(v)) |^2 \right] + \beta , D_{\text{KL}}(q(z|v) | p(z))
]
where ( \beta ) is a weighting factor for the regularization term.
3. Text Encoding
The Text Encoder transforms the text prompt ( T ) into a condition vector ( c ) in the text embedding space ( \mathcal{C} ):
[
c = E_T(T)
]
4. Diffusion Process
The diffusion model defines a forward (noising) process and a reverse (denoising) process in the latent space ( \mathcal{Z} ).
-
Forward Diffusion (Noising) Process:
Starting from ( z_0 = z ), the latent representation is progressively noised over ( T ) timesteps:
[
q(z_t | z_{t-1}) = \mathcal{N} \left( z_t; \sqrt{\alpha_t} , z_{t-1}, (1 - \alpha_t) \mathbf{I} \right)
]
where ( \alpha_t \in (0, 1) ) controls the amount of noise added at each timestep.
The marginal distribution at timestep ( t ) can be expressed as:
[
q(z_t | z_0) = \mathcal{N} \left( z_t; \sqrt{\bar{\alpha}_t} , z_0, (1 - \bar{\alpha}_t) \mathbf{I} \right)
]
with ( \bar{\alpha}t = \prod{s=1}^t \alpha_s ).
-
Reverse Diffusion (Denoising) Process:
The reverse process aims to recover ( z_0 ) from ( z_T ) by iteratively denoising, conditioned on the text embedding ( c ):
[
p_\theta(z_{t-1} | z_t, c) = \mathcal{N} \left( z_{t-1}; \mu_\theta(z_t, t, c), \Sigma_\theta(z_t, t) \right)
]
The mean ( \mu_\theta ) is predicted by the Transformer Network ( \epsilon_\theta ):
[
\mu_\theta(z_t, t, c) = \frac{1}{\sqrt{\alpha_t}} \left( z_t - \frac{1 - \alpha_t}{\sqrt{1 - \bar{\alpha}t}} , \epsilon\theta(z_t, t, c) \right)
]
The variance ( \Sigma_\theta(z_t, t) ) can be fixed or learned.
5. Transformer Network for Noise Prediction
The Transformer Network ( \epsilon_\theta ) predicts the noise ( \epsilon ) added to ( z_0 ) at each timestep ( t ), conditioned on the text embedding ( c ):
[
\epsilon_\theta(z_t, t, c) = \text{TransformerNetwork}(z_t, t, c)
]
6. Training Objective
The model is trained to minimize the difference between the true noise ( \epsilon ) and the predicted noise ( \epsilon_\theta ):
[
L_{\text{diffusion}} = \mathbb{E}{z_0, \epsilon, t} \left[ | \epsilon - \epsilon\theta(z_t, t, c) |^2 \right]
]
where:
-
( z_0 = E_V(v) ) is the initial latent representation.
-
( \epsilon \sim \mathcal{N}(0, \mathbf{I}) ) is the Gaussian noise.
-
( z_t ) is obtained by:
[
z_t = \sqrt{\bar{\alpha}_t} , z_0 + \sqrt{1 - \bar{\alpha}_t} , \epsilon
]
7. Video Generation Pipeline
At inference time, we generate a new video conditioned on a text prompt ( T ):
-
Step 1: Encode the text prompt to obtain the condition vector:
[
c = E_T(T)
]
-
Step 2: Initialize ( z_T ) with Gaussian noise:
[
z_T \sim \mathcal{N}(0, \mathbf{I})
]
-
Step 3: Iteratively apply the reverse diffusion process for ( t = T, T-1, \dots, 1 ):
[
z_{t-1} = \frac{1}{\sqrt{\alpha_t}} \left( z_t - \frac{1 - \alpha_t}{\sqrt{1 - \bar{\alpha}t}} , \epsilon\theta(z_t, t, c) \right) + \sigma_t \omega
]
where:
- ( \sigma_t^2 = \frac{1 - \bar{\alpha}_{t-1}}{1 - \bar{\alpha}_t} (1 - \alpha_t) ).
- ( \omega \sim \mathcal{N}(0, \mathbf{I}) ) introduces stochasticity for improved sample diversity.
-
Step 4: Decode the final latent representation ( z_0 ) to obtain the generated video ( \hat{v} ):
[
\hat{v} = D_V(z_0)
]
Summary of the VideoDiT Pipeline
-
Text Encoding: Convert text prompt ( T ) into condition vector ( c ).
-
Latent Representation: Use VAE to map video data ( v ) into latent space ( z ).
-
Forward Diffusion: Add noise to ( z_0 ) over ( T ) timesteps to obtain ( z_T ).
-
Noise Prediction: Use Transformer Network ( \epsilon_\theta ) to predict noise at each timestep, conditioned on ( c ).
-
Reverse Diffusion: Iteratively denoise ( z_T ) to recover ( z_0 ), guided by ( c ).
-
Video Reconstruction: Decode ( z_0 ) using VAE decoder to generate the video ( \hat{v} ) corresponding to the text prompt.
By following this mathematical pipeline, VideoDiT generates videos that are semantically aligned with the provided text descriptions, leveraging the power of diffusion models conditioned on text embeddings.