TL;DR
A masked diffusion model is a generative model for discrete data, such as a sentence written as a list of tokens. Its forward process hides each token with a probability that grows from 0 to 1, and its reverse process fills the hidden tokens back in, a few at a time. Training reduces to one question asked many times: given the visible tokens, what are the hidden ones? That makes it a way to generate text without writing it strictly left to right.
Builds on: Diffusion Model, Masked Language Modeling, Variational Lower Bound (ELBO) · Leads to: Large Language Diffusion Models
Where it's used
Large language models that do not write left to right. LLaDA is an 8B-parameter language model trained from scratch as a masked diffusion model. Its authors pre-trained it on 2.3 trillion tokens, using about 0.13 million H800 GPU hours, then fine-tuned it on 4.5 million instruction pairs. It is reported to be competitive with LLaMA3 8B on in-context learning, and it can hold a multi-turn conversation. It is among the clearest public evidence that the usual next-token recipe is not the only route to a capable chat model.
Reversal questions. A standard left-to-right model often learns "A is B" but fails on "B is A". LLaDA was tested on 496 pairs of famous Chinese poem lines, where the model must produce either the next line or the previous line. Its authors report that it does about equally well in both directions, and that it beats both Qwen 2.5 and GPT-4o by a large margin on the reverse task. The model has no special rule for reversal; it sees all the tokens at once during training.
Images. MaskGIT (Chang et al., CVPR 2022) used the same idea on image tokens: hide some image tokens, predict them all at once, keep the confident ones, and repeat. Masked diffusion gives this recipe a probabilistic footing, so the same training objective can be applied to text.
How it works
Take one training sentence and walk it through one training step, then through generation.
- Start with a clean sentence of four tokens:
x0 = (the, cat, sat, down). - Draw a number t between 0 and 1 at random. Say t = 0.5. This is the masking level for this step.
- Hide each token independently with probability t. Suppose positions 2 and 4 are hidden. The corrupted sentence is
xt = (the, M, sat, M), where M is a special mask token. - Ask the network to predict the hidden tokens from the visible ones. Suppose it gives the true word "cat" probability 0.4 at position 2, and the true word "down" probability 0.25 at position 4. Only hidden positions count; the visible "the" and "sat" are ignored.
- Turn those probabilities into a loss. Each hidden position contributes its negative log probability, the sum is multiplied by 1 divided by t, and the result is the loss for this step. Here it is 2 times (0.916 + 1.386), which is about 4.61. Check: a worse guess, say probability 0.01, would cost much more.
- Update the network to lower the loss, then draw a new t and a new sentence, and repeat.
Generation runs the same network in reverse.
- Start with a response of four masked tokens:
(M, M, M, M). This is t = 1. - Predict every masked position at once. Keep only the most confident half of the predictions and re-mask the rest. Now two tokens are visible and two are masked. This is t = 0.5.
- Predict the two masked positions and keep all of them. Nothing is masked, so the sentence is finished.
flowchart LR A["Clean sentence x0"] --> B["Draw t between 0 and 1"] B --> C["Hide each token with probability t"] C --> D["Network predicts the hidden tokens"] D --> E["Loss on hidden tokens only, weighted by 1 over t"] E --> F["Update the network"]
The math
A model over sequences x0 = (x0^1, ..., x0^L) of tokens from a vocabulary, plus a mask token M. A forward process hides tokens with a growing probability t, and a learned mask predictor p_θ(x0^i | xt) fills in hidden tokens. The model distribution p_θ(x0) is what the reverse process produces at t = 0.
Step 1 in symbols: the forward process
Each position i is hidden independently with probability t. Write the hidden indicator as 1[xt^i = M], which is 1 when position i is masked and 0 otherwise. Each token is visible with probability 1 minus t. At t = 0 nothing is hidden; at t = 1 everything is hidden. The expected number of hidden tokens is t times L, where L is the sequence length.
Step 2 in symbols: the training draw
The step-2 draw is t ~ Uniform[0, 1]. The masking level is chosen fresh each time, so the network sees every amount of hiding during training. This is the main difference from BERT, which always hides a fixed share of tokens.
Step 4 and 5 in symbols: the loss
The training loss, as written in the LLaDA paper, is
L(θ) = − E[ (1/t) · Σ_{i=1}^{L} 1[xt^i = M] · log p_θ(x0^i | xt) ]
Here the expectation runs over t, the clean sentence x0 and the corrupted sentence xt. The sum adds, over all positions, the log probability of the true token at each hidden position, and the indicator switches off visible positions. The minus sign turns the log probability into a loss to minimise. The 1/t factor is what makes this loss principled: the paper proves that L(θ) is an upper bound on the negative log-likelihood of the data, so lowering it also raises a lower bound on how well the model explains real text. That proof is in the paper's appendix; here we use the bound as given.
Step 6 and 7 in symbols: the reverse step
Going from masking level t to a smaller level s < t, the network predicts all hidden tokens at once. Then it re-masks a fraction s/t of those predictions. Count the masked fraction after the step: before the step it was t; the re-mask keeps a fraction s/t of the predicted positions hidden, so the new hidden fraction is t · (s/t) = s. The schedule therefore lands exactly on the masking level s, which keeps sampling consistent with the forward process. The paper's default re-mask chooses the least confident predictions, not random ones.
Worked examples
Let L = 2 and t = 0.5. Each token is hidden with probability 0.5, independently.
- The four possible hiding patterns are: neither hidden, only position 1 hidden, only position 2 hidden, both hidden.
- Each pattern has probability 0.5 times 0.5, which is 0.25.
- The expected number of hidden tokens is 0 times 0.25, plus 1 times 0.5, plus 2 times 0.25. That is 0 + 0.5 + 0.5 = 1.
- This matches the rule: t times L = 0.5 times 2 = 1.
Let x0 = (the, cat, sat, down) and t = 0.25. Suppose positions 1 and 3 are hidden, so xt = (M, cat, M, down). The network gives the true token at position 1 probability 0.5 and the true token at position 3 probability 0.2.
- The weight is 1/t = 1/0.25 = 4.
- Position 1 contributes −ln(0.5) = 0.6931.
- Position 3 contributes −ln(0.2) = 1.6094.
- Visible positions 2 and 4 contribute nothing.
- The sum is 0.6931 + 1.6094 = 2.3026.
- Multiply by the weight: 4 times 2.3026 = 9.2103.
The loss is large because two hidden tokens were guessed with only moderate confidence, and the weight of 4 amplifies a lightly masked example.
The LLaDA paper reports two ways of generating answers for its 8B instruct model. On GSM8K (grade-school math word problems), pure diffusion sampling scores 69.4, and block-style sampling, which mixes in left-to-right chunks, scores 78.6. On MATH (harder competition math), the two scores are 31.9 and 42.2.
- The gap on GSM8K is 78.6 minus 69.4, which is 9.2 points.
- The gap on MATH is 42.2 minus 31.9, which is 10.3 points.
- In both tasks the mixed sampling is better, and the paper attributes part of this to end-of-sequence padding in the instruction data, which makes pure diffusion stop early.
- Interpretation: the sampling style is a real design choice with a measurable effect of about 9 to 10 points on these benchmarks. A reader should compare like with like, pure with pure or block with block.
Try it: a training step draws t = 0.2 on a sentence of 10 tokens, 3 of which are hidden. The hidden tokens' negative log probabilities add up to 5.0. What is this step's loss? Answer: the weight is 1 divided by 0.2, which is 5. The loss is 5 times 5.0, which is 25.
Common mistakes and tradeoffs
It is tempting to think a masked diffusion model is just BERT. BERT hides a fixed share of tokens and predicts them once. A masked diffusion model draws the hiding level from 0 to 1 at random, uses the 1/t weight, and generates by repeating prediction and re-masking. The weight is what ties the training loss to a likelihood bound; BERT has no such tie. The paper notes that MaskGIT drops the 1/t term and therefore lacks this link to maximum likelihood.
It is tempting to think it writes left to right. In fact each step can fill any position, which is why it handles reversal questions well. But generation needs many passes of the network, one per step. The number of steps is a dial: more steps usually means better quality and slower output.
It is tempting to think it is faster than an autoregressive model. In fact it trades speed for flexibility. The paper states that the model is incompatible with the key-value cache that makes autoregressive decoding cheap, so each step recomputes more.
When to use it. Use masked diffusion when the output can be filled in any order, when you need bidirectional context during generation, or when you want a likelihood bound that holds for discrete data.
When not to use it. Avoid it when a single-pass, low-latency answer matters more than flexibility, or when the existing autoregressive stack is already well tuned for the task.
Alternatives. An autoregressive model is simpler and fast to decode with caches. A block-based hybrid, which the LLaDA paper also studies, sits between the two.
History
In 2021, Austin and colleagues at NeurIPS described structured denoising diffusion for discrete states, which set up diffusion over tokens rather than pixels. In 2022, MaskGIT showed that predicting masked image tokens in a few parallel rounds could produce good images quickly. Through 2024, several groups, including Sahoo et al. and Shi et al., showed that a simple masked objective could work well for text, and that its training loss could be written as a weighted sum over hidden tokens. In 2025, LLaDA scaled the approach to an 8B language model with instruction tuning, which made it a serious alternative to next-token models. It caught on because it reached competitive scores while breaking the assumption that the left-to-right order is required.
Recap
- A discrete diffusion process hides tokens with a probability t that runs from 0 to 1.
- The network learns to predict the hidden tokens from the visible ones, and the loss is a weighted sum of negative log probabilities at hidden positions, with weight 1/t.
- The 1/t weight makes the loss an upper bound on the negative log-likelihood, which is the reason for the objective.
- Sampling starts fully masked and unmasks in steps, re-masking a fraction s/t at each step so the schedule matches the forward process.
- Read next: Large Language Diffusion Models, which applies this model at 8B scale.
Check yourself
QuestionRecall: in the forward process, how many tokens are hidden on average in a sequence of length L when the masking level is t?Show answer
On average t times L tokens are hidden, since each token is hidden independently with probability t.
QuestionA sentence has 4 tokens, t = 0.5, and two positions are hidden. The network gives the true tokens probabilities 0.5 and 0.5. What is the loss for this step?Show answer
The weight is 1/0.5 = 2. Each hidden position contributes −ln(0.5) = 0.6931, so the sum is 1.3863. Multiplying by 2 gives 2.7726.
QuestionWhy does the masked diffusion loss use a random masking level t rather than a fixed share of hidden tokens, as BERT does?Show answer
A random t lets the network see every amount of hiding during training, from almost nothing to almost everything. This matches the reverse process, which passes through every level from 1 down to 0. The 1/t weight then turns the average over levels into a bound on the likelihood of the data. A fixed share would train the network on only one level, and the bound would not hold for the full generation process.
QuestionA reader wants to compare two systems. One reports GSM8K 69.4 with pure diffusion sampling, the other reports 75.0 with a left-to-right model. Is the comparison fair?Show answer
Not as stated. The sampling method differs, and the paper shows that sampling style alone can move GSM8K by about 9 points. A fair comparison needs the same model, the same data and the same sampling method, or the difference must be reported with its cause.
Sources
- Large Language Diffusion Models (LLaDA), Nie et al., 2025.
- Simple and Effective Masked Diffusion Language Models, Sahoo et al., 2024.
- Simplified and Generalized Masked Diffusion for Discrete Data, Shi et al., 2024.