๐ณ LLaDA; Large Language Diffusion Models (2025-02)
์ต๊ทผ ๋ฑ์ฅํ Diffusion Models๋ค์ ARMs (Autoregressive Models) ๋งํผ ์ฑ๋ฅ์ด ๊ด์ฐฎ์ ํธ์ด๊ณ , context-awareness ์์ญ์์๋ ์ฑ๋ฅ์ด ๋ ๊ฐํ๋ค๋ ํ์ด ๋์ค๊ณ ์๋ค. โ DLMs์ด ์ ํต ARMs ๋์ฒดํ ์๋ก์ด ๋์์ผ๋ก ๋ถ์ํ๊ณ ์๋ ๊ฒ ๊ฐ๋ค.

1/ Background : Diffusion Models

Diffusion Model์ generative models์ ํ ์ข ๋ฅ๋ก, random noise๋ฅผ ์ ์ง์ ์ผ๋ก ์ถ๊ฐ (forward), ์ ์ง์ ์ผ๋ก denoise (reverse)ํ๋ฉด์ ๋ฐ์ดํฐ๋ฅผ ์์ฑํ๋ค.
๋ค์ํ noise๋ฅผ ์ถ๊ฐํ๊ณ , ์ด๋ฅผ ๋ณต์ํ๋ ๋ฒ์ ๋ชจ๋ธ์ด ํ์ตํ๋๋ก ํ๋ จ์ํค๋ ๋ฐฉ๋ฒ์ด๋ค. ์์ฑ ์์๋ random input์ ๋ฐ๋ณต์ ์ผ๋ก ์ ๋ฐ์ดํธํด ๊ฒฐ๊ณผ๋ฅผ ์ ์ฐจ ์ ์ ํ๋ฉฐ, ํจ์จ์ ์ธ sampling์ ํตํด ์ ์ step์ผ๋ก๋ ๊ณ ํ์ง ๋ฐ์ดํฐ๋ฅผ ์์ฑํ ์ ์๋ค. ์ดํ conditioning, guidance ๊ธฐ๋ฒ์ ํตํด ์ถ๋ ฅ ์กฐ์ ์ด ๊ฐ๋ฅํ๋ค.
์ด๋ฏธ์ง ์์ฑ ๋ถ์ผ์์ ์ฑ๊ณต์ ์ด์๋๋ฐ, ์ต๊ทผ ํ ์คํธ ์์ฑ์๋ ์ ์ฉ๋๋ ์์ง์์ ๋ณด์ด๊ณ ์๋ค.
ARMs์ ์์ฐจ์ ์ผ๋ก ์์ฑํ๋ ๋ฐ๋ฉด, diffusion ๋ชจ๋ธ์ ํ ์คํธ ์ ์ฒด๋ฅผ ๋์์ ์์ฑํ๊ณ , ๋ฐ๋ณต์ ์ธ ์์ ๊ณผ์ ์ ๊ฑฐ์ณ ์ต์ข ์ถ๋ ฅ์ ์์ฑํ๋ค. โ ์์ฑ ์๋, ํจ์จ์ฑ ํฅ์ e.g. Inception Labs์ Mercury
# Set the noise scheduler
noise_scheduler = DDPMScheduler(
num_train_timesteps=1000, beta_schedule="squaredcos_cap_v2"
)
# Training loop
optimizer = torch.optim.AdamW(model.parameters(), lr=4e-4)
losses = []
for epoch in range(30):
for step, batch in enumerate(train_dataloader):
clean_images = batch["images"].to(device)
*# Sample noise to add to the images*
noise = torch.randn(clean_images.shape).to(clean_images.device)
bs = clean_images.shape[0]
*# Sample a random timestep for each image*
timesteps = torch.randint(
0, noise_scheduler.num_train_timesteps, (bs,), device=clean_images.device
).long()
*# Add noise to the clean images according to the noise magnitude at each timestep*
noisy_images = noise_scheduler.add_noise(clean_images, noise, timesteps)
*# Get the model prediction*
noise_pred = model(noisy_images, timesteps, return_dict=False)[0]
*# Calculate the loss*
loss = F.mse_loss(noise_pred, noise)
loss.backward(loss)
losses.append(loss.item())
*# Update the model parameters with the optimizer*
optimizer.step()
optimizer.zero_grad()
if (epoch + 1) % 5 == 0:
loss_last_epoch = sum(losses[-len(train_dataloader) :]) / len(train_dataloader)
print(f"Epoch:{epoch+1}, loss: {loss_last_epoch}")2/ TL;DR
LLaDA๋ pre-training๊ณผ supervised fine-tuning (SFT) ๋ฐฉ์์ผ๋ก scratch๋ถํฐ ํ์ต๋ diffusion-based LLM์ผ๋ก, masking (forward process)์ denoising (reverse process - predicting masked tokens) ๊ณผ์ ์ ํตํด ํ๋ฅ ์ ์์ฑ ๋ฅ๋ ฅ์ ๊ฐ์ท๋ค. ARMs (e.g. LLaMA3-8B) ๋๋น ๋์ scalability,์ in-context learning ์ฑ๋ฅ์ ๋ณด์ฌ์ฃผ๋ฉฐ, instruction-following ๋ฅ๋ ฅ๋ ์ฐ์ํ๋ค. ํนํ reversal curse ๋ฌธ์ ๋ฅผ ๊ทน๋ณตํ๋ฉฐ โReversal Poem Completionโ task์์ GPT-4o๋ณด๋ค ๋ฐ์ด๋ ์ฑ๋ฅ์ ๋ณด์ฌ์ค๋ค. โ ARMs์ ๋์ ๊ฐ๋ฅ์ฑ์ด ๋์ ๊ฒ ๊ฐ๋ค.
Case
Prompt:ย *Explain what artificial intelligence is.*

https://ml-gsai.github.io/LLaDA-demo/
3/ LLaDA (Largeย Languageย Diffusion with mAsking)

Idea
Diffusion์ ์ผ๋ฐ์ ์ผ๋ก ์ด๋ฏธ์ง ์์ฑ์ ์ฌ์ฉ๋๋ ๋ฐฉ์์ด๋ค. โ ํ ์คํธ์ ๊ฒฝ์ฐ, ์ด๋ฏธ์ง์ฒ๋ผ continuous space๊ฐ ์๋๋ฏ๋ก, discrete latent space์์ diffusion์ ์ํํ๋ ๋ฐฉ์์ผ๋ก ์์ฉํ๋ค.
์ด๋ฏธ์ง : ์ฐ์์ ์ธ ํฝ์ ๊ฐ (์ฐ์ ํ๋ฅ ๋ถํฌ) ๋ณดํต UNET ๊ธฐ๋ฐ Gaussian Noise ์ ์ง์ ์ผ๋ก ์ถ๊ฐ โ ๋ ธ์ด์ฆ ์ ๊ฑฐํ๋ฉด์ ์ด๋ฏธ์ง ๋ณต์
ํ ์คํธ : ์ด์ฐ์ ์ธ ํ ํฐ (์ด์ฐ ํ๋ฅ ๋ถํฌ) โdiscrete diffusionโ Transfomer ๊ธฐ๋ฐ LLaDA : 0 ~ 1 ์ฌ์ด์ ์์์ masking ๋น์จ์ ์ฌ์ฉํด ํ ํฐ์ ์ ์ง์ ์ผ๋ก masking โ masking๋ token ์์ธกํ๋ฉด์ ๋ณต์ํ๋ค.
$$ P(x_{ti} | x_{i}) = \begin{cases}1 - t & \text{if} \; x_{ti} = x_{i} \\ t & \text{if} \; x_{ti} = [MASK]\end{cases} $$
Methods

LLaDA๋ masked diffusion model๋ก, pre-training, SFT(Supervised Fine-Tuning), sampling ์ธ ๊ณผ์ ์ผ๋ก ๋์ ๊ณผ์ ์ ๋๋ ๋ณผ ์ ์๋ค.
- Pre-training
input sequence์ ๋ชจ๋ token์ ๋ฌด์์๋ก ๋ ๋ฆฝ์ ์ผ๋ก masking.
masking ratio $t$๋ [0,1]์์ ๋๋ค์ผ๋ก ์ํ๋ง (๊ฐ token์ $t$์ ํ๋ฅ ๋ก masking๋จ)
$t=1$์์ ๋ชจ๋ token์ด masking๋๊ณ , ์ด ์์ ์ ์์ฑ๋ sequence๋ฅผ $x_1$
๋ชจ๋ธ์ mask predictor๋ก ๊ฐ position์ masked token์ ๋ณต์ํ๋ ๋ฐฉ์์ผ๋ก ํ์ต.
diffusion์ forward process์ ์ ์ฌํ๊ฒ ๋ฐ์ดํฐ๋ฅผ ์ ์ฐจ noise (mask)๋ก ๋ง๋๋ ๊ณผ์ .
- SFT (Supervised Fine-Tuning)

- Prompt๋ ๊ณ ์ , Response ๋ถ๋ถ๋ง ๋ง์คํฌ
- ๋ชจ๋ธ์ masking๋ response ๋ถ๋ถ์ ์์ธกํ๋๋ก fine-tuning.
- Mask prediction loss๋ก ํ์ต.
Sampling
- $t=1$ (๋ชจ๋ token์ด mask๋ ์ํ)์์ ์์ํ์ฌ $t=0$๊น์ง ์งํ.
- mask predictor๋ฅผ ํตํด mask ๋ณต์ (masking๋ ๋ชจ๋ token์ ๋์์ ์์ธก) maksing๋ token์ด ๋ฌด์์ธ์ง ์์ธก.
- ์์ธก ํ ์ผ๋ถ token์ unmask๋๊ณ ์ผ๋ถ๋ ๋ค์ remask (flexible remasking)
- ์ด๋ฅผ ๋ฐ๋ณตํด ์ ์ง์ ์ผ๋ก $t=0$ (๋ชจ๋ token์ด unmask๋ ์ํ) ์์ ํ ๋ณต์.
Forward process : ์ ์ง์ masking, Reverse process : iterative unmasking
Sampling์์ remasking & refine ๊ณผ์ ์ ๊ฑฐ์น๋ฉฐ ๋์ ํ์ง๊ณผ long-context ์ธ์ง ๋ฅ๋ ฅ์ ํ๋ณด.
ARMs์ next-token-generation ๋ฐฉ์๋ณด๋ค global context ์ดํด๋๊ฐ ๋ ๋์.
Architecture
๋ง์คํฌ๋ ์ด๊ธฐ ์ํ (xโ; t=1)
โ
โผ
Mask Predictor (Transformer)
โ
์์ธก๋ ํ ํฐ (์ผ๋ถ๋ ๋ค์ ๋ง์คํฌ๋จ)
โ
โผ
Remasking (Remasking ์ ๋ต์ ๋ฐ๋ผ)
โ
โผ
๋ฐ๋ณต์ ์ ์ (t: 1 -> 0)
โ
โผ
์ต์ข
ํ
์คํธ (xโ; t=0)- Transformer ๊ธฐ๋ฐ mask predictor & multi-head attention block ํฌํจ.
Training
Training Objective
$$ L(\theta) \triangleq -E_{t, x_0, x_t} \left[ \frac{1}{tL} \sum_{i=1}^L \mathbb{1}[x_{it} = M] \log p_\theta (x_{i0}|x_t) \right] $$random timestep $t$ ์ ํ.
์์ ํ ์คํธ์ noise (mask) ์ถ๊ฐ.
$q(x_t|x_0)$
๋ชจ๋ธ์ด masking๋ token ์์ธก.
$x_t$๋ฅผ ์ ๋ ฅ ๋ฐ์ masking๋ ์์น์ ์๋ token์ ์์ธก.
Loss : Cross-Entropy Loss
์์ธก๋ token๊ณผ ์ค์ token ๊ฐ์ Cross-Entropy Loss๋ฅผ ๊ณ์ฐํ๊ฒ ํด ๋ชจ๋ธ ์ ๋ฐ์ดํธ.
Sampling (Inference)
์ด๊ธฐ ์ํ ์ค์
๋ชจ๋ token์ด masking๋ ์ด๊ธฐ sequence $x_1$ ์ค์ .
denoising ๋ฐ๋ณต $(t: 1 \rightarrow 0)$
$t$๋ฅผ 1์์ 0์ผ๋ก ์ ์ฐจ ์ค์ฌ๋๊ฐ๋ฉด์ ๋จ๊ณ ๋ฐ๋ณต.
mask predictor $p_{\theta}(x_0|x_t)$๋ฅผ ์ฌ์ฉํด masking๋ token ์์ธก. ์์ธก๋ ํ๋ฅ ๋ถํฌ๋ฅผ ์ฌ์ฉํด ๊ฐ token์ด ํด๋น ์์น์ ์์ ํ๋ฅ ํ์ . ๊ฐ์ฅ ๋์ ํ๋ฅ ์ ๊ฐ์ง token์ ์ ํํ๊ฑฐ๋, ํ๋ฅ ๋ถํฌ์ ๋ฐ๋ผ ๋ฌด์์๋ก token ์ ํ ๊ฐ๋ฅ.
Remasking : ์์ธก๋ token ์ค ์ผ๋ถ๋ฅผ ๋ค์ masking.
์ต์ข ํ ์คํธ ์์ฑ
$t=0$์ด๋ฉด ์ต์ข ํ ์คํธ $x_0$ ์์ฑ.
Accelerate:
- Pseudo-numerical solvers (DDIM)์ด๋ fewer-step sampling ๊ธฐ๋ฒ ์ฌ์ฉ. diffusion์ ๊ทผ์ฌํ๋ ์์น ํด๋ฒ์ ์ฌ์ฉํด ๋ ์ ์ ๋จ๊ณ๋ก ๊ณ ํ์ง ์ํ ์์ฑ. diffusion ๊ณผ์ ์ ๊ฐ ๋จ๊ณ๋ฅผ ์ต์ ํํ๊ฑฐ๋ ๋ถํ์ํ ๋จ๊ณ๋ฅผ ์ ๊ฑฐํด ์ถ๋ก ์๋ ํฅ์.
- ์ต๊ทผ์๋ 5~10 step๋ง์ผ๋ก๋ ์ถฉ๋ถํ ๋์ ํ์ง ์์ฑ์ด ๊ฐ๋ฅํ Fast DLM ์ฐ๊ตฌ๋ ์งํ ์ค.
Scalability

Reference
- Large Language Diffusion Models (arXiv 2502.09992)
- Large Language Diffusion Models - Hugging Face Papers
- Is the Mercury LLM the first of a new generation of LLMs?
- Paper Review: Large Language Diffusion Models - Andrey Lukyanenko
- ML-GSAI/LLaDA: Official PyTorch implementation for Large Language Diffusion Models
- Inception Labs News