Search

Search papers and lessons

Large Language Diffusion Models

Shen Nie, Fengqi Zhu, Zebin You et al. · 2025

LLaDA trains a Transformer to fill in randomly masked tokens and generates text by unmasking a blank sequence, scaling this masked diffusion approach to 8 billion parameters.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Neural network basics
  • Linear algebra
  • Pre-training
  • ReadReady to readNot yet

TL;DR

Almost every large language model writes text one token at a time, left to right. LLaDA asks whether that order is essential. It hides random tokens of a training text, trains a Transformer to recover them, and generates by starting from a fully hidden answer and revealing tokens over several steps. The authors scale this masked diffusion approach to 8 billion parameters trained from scratch on 2.3 trillion tokens. The 8B model is reported as competitive with LLaMA3 8B on many benchmarks, and it performs consistently in both directions on a poem-reversal test where Qwen 2.5 and GPT-4o show a clear gap.

Builds on: Masked Diffusion Model, Variational Lower Bound (ELBO), Transformer, Instruction Tuning · Leads to: later work on diffusion language models at scale

Why it mattered

Until this paper, diffusion models had won on images and other continuous data, but no diffusion language model had been shown at the scale of a modern LLM. The authors' main claim is that the core abilities of LLMs, namely scaling, in-context learning and instruction following, come from the training principle (maximum likelihood) and the Transformer, not from the left-to-right order. If that holds, the order is a design choice rather than a requirement.

The paper gives three concrete reasons to care. It trains an 8B model with no autoregressive component, using about 0.13 million H800 GPU hours for pre-training. It reports that the model supports multi-turn dialogue after supervised fine-tuning. And it reports a result on the reversal curse, where a model that learns "A is B" from text often fails on "B is A". The reversal curse is a failure of left-to-right training, in which a model that learns "A is followed by B" often cannot give A from B. The paper's reversal test, on poem lines, is a direct way to check it.

The problem

A standard language model is trained by maximum likelihood on the next-token factorisation. For a sequence of L tokens,

pθ(x)=pθ(x1)∏i=2Lpθ(xi∣x1,…,xi−1)p_\theta(x) = p_\theta(x^1) \prod_{i=2}^{L} p_\theta(x^i \mid x^1, \dots, x^{i-1})

Each token is predicted from the tokens before it. This is the Autoregressive Model form. It is exact and works well, but it means that the model only ever conditions on the left. The paper argues that the question to ask is whether the training principle, maximising the likelihood of the data under the model, needs this factorisation. Earlier diffusion work on text had not reached LLM scale, and it was unclear whether a masked, bidirectional alternative could match an autoregressive model on the same data.

How it works

There are two processes: training, which teaches a mask predictor, and generation, which uses it. Take a tiny sentence of three tokens, "the cat sat", to see both.

Training, one example:

  1. Take a training sequence. Let x0x_0 be "the cat sat". The model is trained on many such sequences, with a fixed length of 4096 tokens in pre-training.
  2. Pick a masking level. Draw tt uniformly from the interval [0,1][0, 1]. Suppose t=0.5t = 0.5.
  3. Mask each token independently. Each token is replaced by a mask symbol M with probability tt. Suppose "cat" is masked, giving xtx_t = "the M sat". Check: on average half the tokens are masked at t = 0.5, here one of three.
  4. Predict the masked tokens. The mask predictor, a Transformer without a causal mask, reads the whole of xtx_t and gives a probability for every word at each masked position. Suppose it gives "cat" a probability of 0.25.
  5. Score only the masked positions. The loss is 1t\frac{1}{t} times the sum, over masked positions, of the negative log-probability of the true token. Here that is 10.5×(−ln⁡0.25)=2×1.386=2.77\frac{1}{0.5} \times (-\ln 0.25) = 2 \times 1.386 = 2.77. Check: unmasked tokens are never scored, so the model learns to recover missing tokens from context on both sides.
  6. Update the weights. Take a gradient step with AdamW, as in ordinary training.

Generation, for a three-token answer with two steps:

  1. Start fully hidden. The response starts as M M M. The prompt, if there is one, is kept visible.
  2. First step, from t=1t = 1 to s=0.5s = 0.5. The predictor fills in all three masks at once. Suppose the confidences are 0.9 for "the", 0.4 for "cat" and 0.6 for "sat". The low-confidence rule keeps floor(3 × (1 − 0.5)) = 1 token, the one with the highest confidence, so the state becomes "the M M".
  3. Second step, from s=0.5s = 0.5 to 0. The predictor fills the two remaining masks. Every position is now visible, and the output is "the cat sat". Check: the number of hidden tokens fell from 3 to 2 to 0, which matches the schedule.
flowchart LR
  A["Clean text x0"] --> B["Mask each token with probability t"]
  B --> C["Mask predictor reads the whole sequence"]
  C --> D["Cross-entropy on masked tokens, scaled by 1 over t"]
  D --> E["AdamW update"]
  F["Fully masked answer"] --> G["Predict all masks"]
  G --> H["Keep the most confident tokens, re-mask the rest"]
  H --> G

The math

The forward process. For each token independently, the forward process keeps the original token with probability 1−t1 - t and replaces it by M with probability tt. Formally, for each position ii,

qt∣0(xti∣x0i)={1−t,xti=x0it,xti=Mq_{t|0}(x_t^i \mid x_0^i) = \begin{cases} 1 - t, & x_t^i = x_0^i \\ t, & x_t^i = \text{M} \end{cases}

At t=0t = 0 nothing is masked, and at t=1t = 1 everything is masked. The masking probability grows linearly with tt, which the paper motivates by the assumption that the information in a text is proportional to its number of tokens.

Step 2 in symbols: the mask predictor

A mask predictor pθ(⋅∣xt)p_\theta(\cdot \mid x_t) takes the partly masked sequence and predicts every masked token at once. Training minimises

L(θ)=−Et,x0,xt[1t∑i=1L1[xti=M]log⁡pθ(x0i∣xt)]\mathcal{L}(\theta) = -\mathbb{E}_{t, x_0, x_t}\left[\frac{1}{t} \sum_{i=1}^{L} \mathbf{1}[x_t^i = \text{M}] \log p_\theta(x_0^i \mid x_t)\right]

The indicator 1[xti=M]\mathbf{1}[x_t^i = \text{M}] is 1 at masked positions and 0 elsewhere, so only masked tokens contribute. Because each token is masked with probability tt, the masked positions are a fraction tt of the sequence in expectation. Dividing by tt rescales the sum back to the full sequence. The paper shows that this loss is an upper bound on the negative log-likelihood of the model:

−Epdata(x0)[log⁡pθ(x0)]≤L(θ)-\mathbb{E}_{p_{\text{data}}(x_0)}\left[\log p_\theta(x_0)\right] \le \mathcal{L}(\theta)

This bound is what makes the approach a principled generative model, as opposed to a masked-language-model objective with a fixed masking rate such as BERT's. The paper notes that BERT masks a fixed fraction of tokens, while LLaDA draws the fraction at random from 0 to 1. A related method, MaskGIT, drops the 1t\frac{1}{t} factor and so has no link to maximum likelihood.

Step 6 in symbols: sampling

The reverse process moves from t=1t = 1 to t=0t = 0. In the paper's default, the low-confidence variant, at each step the model predicts every masked token, keeps the predictions it is most sure of, and re-masks the rest. With NN steps and s=t−1/Ns = t - 1/N, the number of tokens left unmasked after the step is

nun=⌊L(1−s)⌋n_{\text{un}} = \lfloor L (1 - s) \rfloor

This is the rule used in the walkthrough. The paper also gives a purely random remasking rule, which re-masks a fraction s/ts/t of the predicted tokens, but it is the confidence-based rule that the authors use for their main results.

Conditional likelihood

For supervised fine-tuning, the prompt p0p_0 stays visible and only the response r0r_0 is masked. The loss is the same as above, restricted to response tokens and conditioned on the prompt. To score a candidate response, the paper uses a Monte Carlo estimate in which ll is drawn uniformly from {1,…,L}\{1, \dots, L\}, exactly ll tokens are masked, and each masked token is weighted by L/lL / l. This form has lower variance than masking each token with probability tt. The authors report that the first form needed more than 1000 Monte Carlo estimates for stable results, while this one was stable with 128.

Results

Scale and training. The paper trains LLaDA at 1B and 8B parameters. Pre-training uses 2.3 trillion tokens, a fixed sequence length of 4096, and a learning rate of 4×10−44 \times 10^{-4} with a warmup over the first 2000 iterations. The 8B model takes about 0.13 million H800 GPU hours, and the authors say this is similar to autoregressive models of the same size and data. Supervised fine-tuning uses 4.5 million prompt-response pairs for 3 epochs. The authors state that the 8B runs were not tuned.

Scaling. Compared with autoregressive baselines trained on the same data, LLaDA's performance on six tasks grows with compute up to about 102310^{23} FLOPs. The authors extend the compute range studied earlier for masked diffusion models, which was 101810^{18} to 102010^{20} FLOPs, to 102010^{20} to 102310^{23} FLOPs. They note that earlier work estimated diffusion models need 16 times more compute than autoregressive models for the same likelihood, but they argue the metrics are not directly comparable.

Benchmarks. The authors report that the 8B base model beats LLaMA2 7B on nearly all of 15 zero- and few-shot tasks, and that it is on par with LLaMA3 8B. Its advantages are in math and Chinese tasks. After fine-tuning, the instruct model is reported to be slightly behind LLaMA3 8B Instruct, since no reinforcement learning was used. The paper gives the GSM8K and Math scores for the instruct model as 69.4 and 31.9 with pure diffusion sampling. With block-style sampling they rise to 78.6 and 42.2, and the authors attribute the gain to EOS padding in the fine-tuning data, which causes early termination under low-confidence remasking.

Reversal. On a set of 496 Chinese poem sentence pairs, the models must produce the next line (forward) or the previous line (reversal) with no further training. The authors report that LLaDA performs consistently on both, while Qwen 2.5 and GPT-4o show a clear gap between the two. The reversal scores are in the paper's Table 4 and are not quoted here.

Speed. On GSM8K and Math, LLaDA 8B Base reaches comparable accuracy to LLaMA3 8B Base and achieves 1.5 and 1.8 times the throughput. The authors point out that LLaMA3 uses a key-value cache and LLaDA has no inference optimisation.

Limits. The authors list several. The generation length is a user-chosen number, though they say results are insensitive to it. No specialised attention or positional design was used, and no KV cache. The autoregressive baselines were trained only up to 102310^{23} FLOPs, so the comparison is not at the largest scale. No reinforcement learning alignment was done. The paper also reports that MMLU dropped after fine-tuning, which the authors attribute to fine-tuning data quality.

Reading guide

Check yourself

QuestionRecall: what does the mask predictor predict, and at which positions is the loss computed?Show answer
It predicts the original tokens at every masked position, all at once, from the partly masked sequence. The loss is computed only at masked positions, so unmasked tokens are never scored.
QuestionComputation: a training example has 8 tokens and t = 0.25. Two tokens are masked, and the predictor gives each of them probability 0.5 for the true token. What is the loss for this example, using the 1 over t weighting?Show answer
The negative log-probability at each masked position is -ln 0.5 = 0.693, and the two masked positions give a sum of 1.386. Multiplying by 1 over t = 4 gives 5.55.
QuestionWhy: the walkthrough keeps only the most confident tokens at each step, although the paper says the remasking 'should be purely random' in principle. Why do the authors use the confidence rule anyway?Show answer
They say they adopt it inspired by annealing tricks used when sampling from LLMs. The paper says it borrows this from annealing tricks used when sampling from LLMs, in place of the purely random rule that the theory suggests. A plausible reason is that fixing the most confident positions first gives later predictions more context. The paper does not test this directly, so treat it as motivation rather than a measured result.
QuestionApplied: a team wants to test whether a diffusion language model handles reversal better than their left-to-right model. Using this paper, what should they measure, and what would count as evidence for the claim?Show answer
They should build a set of forward and reversal pairs, like the paper's poem lines, and compare zero-shot accuracy in both directions for each model. Evidence for the claim would be a small gap between directions for the diffusion model and a clear gap for the left-to-right model, on the same data. The paper's own evidence is one dataset and one size, so they should check on their own data.

Sources

Read the full paper

Shen Nie, Fengqi Zhu, Zebin You et al., 2025. arXiv:2502.09992