1. Discrete-Time ELBO Perspective

1.1 Variational Diffusion Framework

Forward Process (Diffusion): We define a forward noising Markov chain that gradually corrupts the data into noise . At each discrete time step , a known transition distribution injects noise. For a masked diffusion model, typically replaces each token with a mask symbol (or draws from a “prior” distribution ) with some probability. For example, an absorbing-state forward process can be written as:

where controls the masking rate at step , and is a fixed prior distribution over tokens (e.g. placing all mass on the mask token). In words, with probability each token stays the same, and with probability it is resampled from (masked). Repeating this for to yields that is fully “noise” (e.g. all masks) with high probability () ().

Reverse Process (Denoising): We train a parameterized reverse Markov chain to undo the diffusion. Here is a known prior at (often set to the same so that is distributed as the forward process’s stationary distribution ()). The conditional (sometimes called the decoder or denoiser) is a neural network that attempts to predict a less noisy given a noisier . Its form will be learned via maximum likelihood.

ELBO Objective: Our goal is to maximize the data log-likelihood . We use the standard evidence lower bound (ELBO) derivation for latent-variable models. Introducing the forward process as a variational distribution, we have for any :

  • ELBO:

Expanding the joint probabilities gives a sum across time. We write (with since is given), and similarly expand . Plugging in:

Here we have grouped terms by time step. Rearranging the expectation of differences into KL-divergences, the negative ELBO (NELBO) (which we minimize during training) can be written as a sum of KL terms for each diffusion step ():

  • Negative ELBO:

Each term compares the model’s predicted reverse distribution to the true posterior . If we choose (i.e. the model’s prior matches the forward process at ), the last KL vanishes (). We focus on the diffusion terms. Intuitively, this objective asks the model to match the true reverse dynamics at each step , so that the overall reverse chain produces realistic .

1.2 Posterior Distribution via Data-Ratio (Bayes) Method

A core challenge is to derive the true posterior of the diffusion process – i.e. the probability that the -step state was some value, given the current state and the original data . Using Bayes’ rule on the Markov chain:

  • Bayes Posterior:

Each factor on the right is obtainable from the forward process:

  • is just the one-step transition probability (known by design of ).
  • is the -step marginal starting from (which can be computed by composing transitions).
  • is the -step marginal from .

This “data distribution ratio” form () () lets us compute the posterior in closed form for common diffusion schedules. For the absorbing mask diffusion (with concentrated on the mask token m), the posterior can be derived by considering two cases for a given token: (a) the token is unmasked at time (i.e. ), or (b) it is masked at time ():

  • Case 1 (Token unmasked at ): . This means the token never got masked in the first steps. In fact, if is still the original token, then must also equal (once a token masks, it stays masked). Thus , and probability of is . In other words, if , the posterior is a delta at . (This is consistent with Bayes’ formula: is the survival probability , and is ; plugging into Bayes gives 1.)
  • Case 2 (Token masked at ): . This event can happen via two forward paths: either the token became masked for the first time at step , or it was already masked at . In the former sub-case, was and then got masked at step ; in the latter, was as well. Using Bayes’ formula:
    where is the probability of masking at step . Similarly,
    since (once masked, it stays masked) and is the probability the token was masked by time . We can simplify these expressions using (the cumulative survival probability up to ) and :

These results articulate the true posterior in closed form () (). In summary, for each token position:

  • If the token is unmasked at time , the reverse-time posterior is a delta on the original token.
  • If the token is masked at , the reverse posterior is a Bernoulli distribution: with some probability (proportional to ) the token was the original at and just got masked, and with the remaining probability it was already masked at .

1.3 Deriving the ELBO Training Loss

Plugging the posterior into the NELBO sum, we obtain an explicit loss at each time step. The KL divergence in the -th term compares a discrete target distribution (given by the above ) to the model’s output :

  • Step- KL:

Using the two cases above, this KL can be written in closed form for masked diffusion () ():

  • If (unmasked), then puts all mass on . In this case, the KL reduces to (since the “true” distribution is a delta) plus 0 for the model’s probability on . In fact, the optimal model would deterministically predict in this scenario, making this term zero () ().
  • If (masked), then is split between and . Writing for brevity, the KL is:

This is the KL between a Bernoulli and the model’s Bernoulli output for “was original vs was mask.” Minimizing it w.r.t. is equivalent to a binary cross-entropy fitting to match q__. In particular, the gradient of this KL w.rt. the model’s logit is proportional to p_\theta(x_{t-1}=x_0|x_t=m) - q__, showing that the model is trained to output q__ as its probability for when is masked.

Now, assembling the overall loss, the expected KL over can be interpreted as an expectation over the two cases with their respective probabilities. Equivalently, we can write the NELBO as a sum of cross-entropy terms weighted by how likely each case is under the forward process:

where we have used that covers both cases: if , then so the term is ; if , then the expectation over gives a factor q__ inside the log term, exactly producing the cross-entropy with target probability q__. In other words, the model is trained to output as the posterior probability that the token was originally , under the diffusion process. The loss sums the negative log of those probabilities, averaged over the diffusion trajectory.

Crucially, for masked diffusion this simplifies to familiar language-modeling losses. Each term is essentially asking the model to predict the original token given a randomly corrupted version . At , is with some tokens masked; predicting from that is exactly a masked language modeling (MLM) task. For , has an even larger random subset of tokens masked – still a similar task, just with a higher masking ratio. Thus the total objective is a weighted mixture of MLM-style prediction losses at varying noise levels (Simple and Effective Masked Diffusion Language Models) (Simple and Effective Masked Diffusion Language Models). In fact, one can show that (with appropriate weighting by , etc.) this NELBO equals a weighted average of cross-entropy losses where the input has a fraction of masks and the target is the original tokens (Simple and Effective Masked Diffusion Language Models) (Simple and Effective Masked Diffusion Language Models). The weighting accounts for the probability a given token is masked at time . After appropriate Rao-Blackwellization and simplification (as done in MDLM () ()), the loss can be written compactly and computed without iterating over all for each example.

Final Loss (ELBO View): In summary, training a masked diffusion language model via ELBO maximization yields a loss of the form:

for some schedule-dependent weights (that can be chosen or optimized for tighter bounds). In practice, one finds that simplify this sum. For example, MDLM uses a simplified weighting such that each term corresponds to an MLM loss with a certain mask probability (Simple and Effective Masked Diffusion Language Models). This variational perspective guarantees that this loss is a valid evidence lower bound on , linking it to principled maximum likelihood training.

2. Score Matching Perspective

2.1 Discrete Score Matching Basics

Diffusion models can also be derived from a score matching perspective, which focuses on matching the model’s gradients to the data distribution’s gradients (scores). In continuous domains, one trains a neural network to approximate the score , and this can be shown to be equivalent to the ELBO objective (). However, in discrete state-spaces (like text), is not continuous, so is not defined. To extend score matching to discrete data, we rely on structured differences or continuous relaxations of discrete variables () ():

  • One approach (Concrete Score Matching () ()) is to embed discrete categories into a continuous simplex (e.g. via a Gumbel-Softmax (Concrete) distribution). The discrete score can then be characterized by ratios of probabilities rather than derivatives. For example, Meng et al. () define the concrete score as the log-probability difference between two discrete states: for states and ,
    This represents how the probability of state at time compares to state – akin to a directional derivative on the probability simplex. The model can be trained to output an approximation of this ratio for any pair of states () (). Matching all such ratios is conceptually equivalent to matching the full discrete distribution.
  • Another view, used in denoising score matching, is to train the model to predict the original data from a noisy input (a denoising autoencoder), and use Vincent’s theorem () which states this is equivalent to score matching. In discrete terms, predicting from for all is a form of denoising objective. For small noise (almost fully corrupted data), this denoising task directly corresponds to the local score of the distribution. As (continuous-time limit), the denoising objective can be shown to recover the score function in closed form () ().

In summary, discrete score matching means we train the model such that for each time , given a corrupted sample , the model’s predictions reflect the gradients of log-probabilities on the discrete state space. This can be formalized either through the probability ratio matching or through an equivalent denoising autoencoder interpretation.

2.2 Score-Matching Objective Derivation

Using the ratio formulation, consider again the true posterior from the forward process. In the continuous-time limit of diffusion (treating as a continuous variable in ), one can derive a score-based loss for discrete diffusion () (). Lou et al. () (SEDD) propose training a model that outputs the approximate ratio for any pair . The objective they derive can be seen as a continuous-time limit of the ELBO:

  • Continuous-Time NELBO (Score Form):
    where are transition rates of the forward process and is a constant from KL expansion () (). Although this looks complicated, its minimization indeed forces for all (i.e. match the probability ratios, hence match the “concrete score” ()). In turn, this enforces the model’s implied reverse probabilities to match the true reverse , just like ELBO minimization does (). This continuous-time objective can be discretized to finite and yields a similar sum over time steps.

To make this more intuitive, we can again think in terms of denoising. A simpler objective that is equivalent (in the limit of small time steps) to the above is:

  • Denoising Score Matching Loss: Minimize for all .

Here is the model’s predicted probability of the original data given the noisy input . This objective directly trains the model to “denoise” into . Pascal Vincent’s result on denoising autoencoders shows that the gradient of the optimal denoiser w.rt. equals the score (). In discrete terms, the optimal classifier satisfies: for any two possible states of ,

meaning the model’s odds between and match the true diffusion odds. This is exactly the ratio condition from above. In practice, instead of explicitly enforcing every ratio, one can just minimize the cross-entropy between and the delta distribution at the true . The model will converge to the correct conditional , which implies it has learned the “score” implicitly (since from one can derive or the log-odds between any two states).

2.3 Equivalence to ELBO-derived Loss

The score matching viewpoint leads to the same functional form of loss as the ELBO method. In fact, the discrete-time ELBO we derived is a sum of denoising cross-entropies at each step, which is exactly what the denoising score matching objective prescribes. We can make the connection concrete:

  • In the ELBO approach, we arrived at for each step (plus constant terms). This is the expected negative log-probability of the correct “denoising” at step .
  • In the score-matching approach, for each we likewise consider . Note that and are closely related — in an ideal model, should equal because if one correctly predicts the original token at the immediate previous step, one is effectively predicting the original data. In MDLM, the model is parameterized such that directly predicts the original (they call this the SUBS parameterization) (Simple and Effective Masked Diffusion Language Models), making exactly the probability of in the model’s output distribution. Thus the objectives coincide.

Both perspectives yield the same final training loss, which is a weighted sum of masked token prediction losses. This loss can be seen as minimizing the KL divergence at each step (ELBO view) or as matching the discrete score function (score-matching view). In practice, one often cites the simplicity of the resulting loss: “a mixture of classical masked language modeling losses” (Simple and Effective Masked Diffusion Language Models). This highlights that each term in the loss corresponds to predicting original tokens from a partially corrupted sequence – the hallmark of BERT-style masked language modeling, now derived as a special case of diffusion-based generative modeling.

Final Loss (Score-Matching View): The training objective can be summarized as ensuring the model’s predictions at each noise level align with the ground-truth conditional probabilities of the data. In denoising form:

which is equivalent to the earlier ELBO loss after appropriate weighting. In conclusion, the masked diffusion language model can be trained either by maximizing a discrete ELBO or by a score-matching (denoising) objective; both approaches yield the same masked cross-entropy loss function (Simple and Effective Masked Diffusion Language Models), providing a principled and efficient way to learn generative language models with diffusion.