betaFeedback

WorksComputer Science

Birth, Death and Diff: Insertion-Based Sequence Generation with Corrections

Abstract

Insertion-based masked diffusion models enable flexible-length, parallel generation by interleaving mask insertion with token unmasking. However, because their generation decisions are irreversible, aggressive parallel decoding can introduce errors that subsequent steps cannot correct, necessitating conservative decoding with more forward passes (NFEs). Moreover, they exhibit higher entropy than standard MDMs because they marginalize over multiple alignments during training and therefore require even more conservative decoding in the absence of a correction mechanism. To address this limitation, we introduce δδMDM, which makes intermediate generations revisable by equipping an insertion-based model with substitution and deletion operations. During training, we expose the model to errors caused by aggressive unmasking and insertion, teaching it to correct its own mistakes. At inference time, we interleave insertion and unmasking with correction steps that can revise previously unmasked tokens and remove unnecessary masks. This mechanism makes aggressive decoding practical, improving both generation speed and quality. δδMDM Pareto-dominates FlexMDM, a vanilla insertion-based MDM, on the speed–quality trade-off. On high-diversity unconditional text generation on OpenWebText, it halves the generative perplexity relative to FlexMDM at the highest inference budget. It also achieves lower generative perplexity at all inference budgets compared to MDM trained from scratch with variable-length padded sequences. On low-diversity conditional text generation on TinyGSM, it matches FlexMDM accuracy with half as many NFEs.

.tocmtchapter

Introduction

Figure 1. Overview of the \updeltaMDM generation process. The plots on the right show GSM8K code-execution accuracy and OpenWebText generative perplexity versus the sampling budget. Numeric annotations on the OpenWebText plot are token-entropy values.

Non-autoregressive language models such as Masked Diffusion Models (MDMs) [19, 22, 13] provide speedups over autoregressive models (ARMs) by producing more tokens per forward pass. However, because they use absolute positions, the masked positions far from the context have high positional uncertainty, i.e., the model may know what to say but not where to place it [15, 8]. This forces MDMs to generate in a block-wise left-to-right manner, thereby limiting their parallelism [13]. Insertion-based Masked Diffusion Models such as FlexMDM [6] grow the sequence incrementally by inserting new [MASK]{\color{mask}{{\textnormal{\texttt{[MASK]}}}}} tokens and unmasking any existing [MASK]{\color{mask}{{\textnormal{\texttt{[MASK]}}}}} tokens simultaneously. This allows the model to draft by placing important tokens at their approximate positions, since later insertions can fill intermediate positions. However, insertion-based models are also prone to dependency errors under parallel decoding, and they have no mechanism to update positions that have already been unmasked, i.e., . Furthermore, when trained with simple denoising objectives, insertion-based models average over possible alignments. This converts positional uncertainty into token uncertainty, i.e., each insertion location may correspond to several possible target tokens, producing a diffuse predictive distribution over the vocabulary. For instance, in the sentence “Your lazy dog jumped over the black box.”, an intermediate state “Your[MASK]{\color{mask}{{\textnormal{\texttt{[MASK]}}}}}black.” forces the [MASK]{\color{mask}{{\textnormal{\texttt{[MASK]}}}}} to distribute probability over all eligible target tokens, such as lazy, dog, and jumped, thereby inflating the predictive entropy. We call this . As a result, confidence-based decoding must stay conservative to avoid errors, sacrificing the speedup of parallel decoding. One way to combat this is to use a non-uniform distribution over alignments during training or, equivalently, learn the unmasking order of the target positions using variational learning, which tightens the ELBO [18, 30]. However, this requires an additional model and can be slow to train as the models get larger.

We take an alternative approach and introduce \updeltaMDM (Delta MDM), a time-blind insertion-based masked diffusion model that learns to revise its own generations. The name \updeltaMDM emphasizes that the model can change both the length (increase or decrease) and the content of a partially generated sequence. Its generation process combines insertion (birth), deletion (death), and token substitution (diff). Deletion removes excess mask tokens, while substitutions are performed using token-to-token transitions. The supervision for these operations is derived by forcing the model to predict aggressively to form a state with potential mistakes and then feeding it back to the model to correct the wrong predictions (Figure 1). At inference time, we interleave the prediction (insertion and unmasking) and correction (deletion and substitution) steps. The knowledge that corrections can fix mistakes in subsequent steps and the model’s time-blindness allow aggressive drafting in the prediction step, thereby improving both the speed and the quality of generation.

We perform a comprehensive evaluation comparing \updeltaMDM with FlexMDM, which does not have a correction mechanism. On the synthetic planning task with controlled complexity, \updeltaMDM achieves a 10×10\times improvement over FlexMDM in the hardest setting (§ 10.1). On high-diversity unconditional text generation on OpenWebText, with matched training and inference compute \updeltaMDM Pareto-dominates FlexMDM in terms of both speed and quality. Moreover, \updeltaMDM keeps improving as the inference budget grows: at 1024 steps it halves the generative perplexity of FlexMDM and reduces that of MDM by 47%, and with only 128 steps it already outperforms both baselines at 1024 steps. At the other extreme, on low-diversity code-based reasoning on TinyGSM, \updeltaMDM matches FlexMDM’s accuracy with half as many NFEs.

We summarize the key contributions of this work below:

  • We introduce a novel self-correction framework for insertion-based masked diffusion models, which is simple and fast to train and requires no auxiliary model.

  • We conduct a comprehensive evaluation of \updeltaMDM across three types of tasks: controlled-complexity synthetic planning, high-diversity unconditional text generation, and low-diversity reasoning via code generation, and find that \updeltaMDM Pareto-dominates FlexMDM on the speed–quality trade-off, while also demonstrating superior inference-time scaling for unconditional generation.

  • We present ablations demonstrating the importance of our design choices and provide qualitative insights into the behavior of \updeltaMDM during generation.

Preliminaries

In this section, we introduce the notation and provide a brief overview of insertion-based masked diffusion models [6].

Insertion-Based Masked Diffusion Models

Let \sX \coloneqq \bigcup_{k=1}^L \sV^k be the space of variable length sequences, where \sV is the vocabulary including a special mask token denoted by [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}}. Denote by p1=pdatap_1=p_{\text{data}} the target data distribution and by p0p_0 the initial distribution, which in our case is a dirac delta on the empty sequence. The generative process xtx_t with tt going from 00 to 11 is a continuous time Markov chain modeled by its transition rates, which are assumed to be independent per sequence position for tractability. For t∈[0,1]t\in [0, 1], an intermediate partial sequence xtx_t is obtained by first sampling a ground truth sequence x1∼p1x_1\sim p_1 and then randomly dropping some positions and masking some according to a schedule. To explain the details, we define some additional notation.

Notation. Define an auxiliary space of partial sequences as \sZ \coloneqq \bigcup_{k\in [\![L]\!]} \sV^k \times \sS_{k}, where \sS_{k} \coloneqq \{(s^1, \dots, s^k)\in [\![L]\!]^k ~ | ~ s^1 < \dots < s^k\} is the space of ordered tuples of positions, LL is the maximum length, [ ⁣[L] ⁣]={1,2,…,L}[\![L]\!]=\{1, 2, \dots, L\}, and superscripts are used to denote index in the sequence. An element of \sZ is a pair (xt,st)(x_t, s_t) consisting of a sequence and its corresponding positions in the clean target sequence x1x_1. Let ℓ(xt)\ell(x_t) denote the length of xtx_t. Every sequence carries a special [E]{{{{\textnormal{\texttt{[E]}}}}}} token at position ℓ(xt)+1\ell(x_t)+1, which is never dropped, masked, or deleted, and we set st0≔0s_t^0 \coloneqq 0 and stℓ(xt)+1≔ℓ(x1)+1s_t^{\ell(x_t)+1} \coloneqq \ell(x_1)+1. For i∈[ ⁣[ℓ(xt)+1] ⁣]i\in [\![\ell(x_t)+1]\!], the ii-th gap is the slot immediately left of xtix_t^i, and gti=sti−sti−1−1g_t^i= s_t^{i} - s_t^{i-1} - 1 is its length, i.e., the number of tokens of x1x_1 missing in that slot. Note that the rightmost gap is the one immediately left of [E]{{{{\textnormal{\texttt{[E]}}}}}}. In order to make the exposition cleaner, we will use [D]{{\color{drop}{{\textnormal{\texttt{[D]}}}}}} to indicate a dropped position. Note that [D]{{\color{drop}{{\textnormal{\texttt{[D]}}}}}} is not part of the vocabulary \sV and is never used by the model. With this added notation, we note that the auxiliary space \sZ is isomorphic to another space \bar \sZ \coloneqq (\sV\cup \{\ensuremath{{\color{drop}{{\textnormal{\texttt{[D]}}}}}}\})^{L}. Specifically, the isomorphism is given by the mapping \ensuremath{f_{\text{contract}}}: \bar \sZ \to \sZ that removes the [D]{{\color{drop}{{\textnormal{\texttt{[D]}}}}}} tokens from \bar z \in \bar \sZ to form xx, while preserving the exact position information in ss to produce z=(x,s)z = (x, s).

Training

For a fixed linear interpolant schedule, an intermediate xtx_t is obtained as follows. Sample x1∼p1x_1\sim p_1, and t∼Uniform(0,1)t\sim \mathop{\mathrm{Uniform}}(0, 1). Then for each i∈[ ⁣[ℓ(x1)] ⁣]i\in [\![\ell(x_1)]\!], the insertion and unmasking times are sampled as \Tins^i\sim \mathop{\mathrm{Uniform}}(0, 1), \Tumask[i]\sim \mathop{\mathrm{Uniform}}(\Tins[i], 1). Obtain zˉt\bar z_t by setting:

\begin{align} \bar z_t^i = \begin{cases} \ensuremath{{\color{drop}{{\textnormal{\texttt{[D]}}}}}}& \Tins[i] > t \\ \ensuremath{{\color{mask}{{\textnormal{\texttt{[M]}}}}}}& \Tins[i] \leq t < \Tumask[i] \\ x_1^i & \Tumask[i] \leq t \end{cases}~~~\text{ for } i\in [\![\ell(x_1)]\!],~~~~~~~\text{ and } \bar z_t^i = \ensuremath{{\color{drop}{{\textnormal{\texttt{[D]}}}}}}\text{for } \ell(x_1) < i \leq L . \tag*{(1)} \end{align}

The input to the model is xtx_t obtained by removing the [D]{{\color{drop}{{\textnormal{\texttt{[D]}}}}}} token markers from zˉt\bar z_t, i.e., xtx_t is the first element of the pair zt=(xt,st)=fcontract(zˉt)z_t = (x_t, s_t) = {f_{\text{contract}}}(\bar z_t) as defined in the paragraph above. Denote this distribution as pt(xt∣x1)p_t(x_t | x_1). The training objective is obtained by minimizing the Bregman divergence between the predicted and target rates. It contains two terms, the insertion loss Lin\mathcal{L}_{{{{\textnormal{in}}}}} and the unmasking loss Lum\mathcal{L}_{{{\color{unmask}\textnormal{um}}}}:

Lum(θ)=E[11−t∑i:xti=[M]−log⁡Kθ,i(x1sti∣xt)],Lin(θ)=E[11−t∑i=1ℓ(xt)+1D(gi(st),gθ,i(xt))].\begin{equation} \mathcal{L}_{{{\color{unmask}\textnormal{um}}}}(\theta) = \mathop{\mathbb{E}}\Big[ \tfrac{1}{1-t} \sum_{i: x_t^i = {{\color{mask}{{\textnormal{\texttt{[M]}}}}}}} -\log K^{\theta, i}(x_1^{s_t^i} | x_t) \Big], \quad \mathcal{L}_{{{{\textnormal{in}}}}}(\theta) = \mathop{\mathbb{E}}\Big[ \tfrac{1}{1-t} \sum_{i=1}^{\ell(x_t)+1} D\big(g^i(s_t), {g}^{\theta,i}(x_t)\big) \Big]. \tag*{(2)} \end{equation}

The expectation in both losses is over x1∼pdata,t∼Uniform(0,1)x_1\sim p_{\text{data}}, t\sim \mathop{\mathrm{Uniform}}(0, 1) and xt∼pt(xt∣x1)x_t \sim p_t(x_t | x_1). Here D(a,b)=alog⁡ab−(a−b)D(a, b) = a\log\frac{a}{b} - (a - b) is the scalar Bregman divergence. Kθ,iK^{\theta, i} is the predicted token distribution at ii-th position, and gi(st)g^i(s_t) is the number of tokens to be inserted in the ii-th gap of xtx_t according to alignment sts_t w.r.t x1x_1, and gθ,i(xt)g^{\theta,i}(x_t) is read off the cell at position ii, which is the [E]{{{{\textnormal{\texttt{[E]}}}}}} cell for the rightmost gap. Therefore, the unmasking loss is nothing but a weighted cross-entropy and the insertion loss simplifies to a regression loss matching the predicted gap length gθ,i(xt){g}^{\theta,i}(x_t) to the true gi(st)g^i(s_t). Note that both the predicted unmasking distribution and the insertion mean condition on the value of tt.

Key Limitation:

The model observes xtx_t but not the alignment sts_t. In a fixed-length MDM, the ii-th mask always corresponds to x1ix_1^i, so the only uncertainty in its target is the content of x1x_1. Once positions are dropped, the same xtx_t can arise from the same x1x_1 under several alignments. In fig:alignment, xt=(A,[M],D)x_t=(A,{{\color{mask}{{\textnormal{\texttt{[M]}}}}}},D) arises from x1=(A,B,C,D)x_1=(A,B,C,D) with either st=(1,2,4)s_t=(1,2,4) or s~t=(1,3,4)\tilde s_t=(1,3,4). Each sample supervises a single token, but the minimizer of (2) is the mixture ∑sp(st=s∣xt) p(x1si∣xt,st=s)\sum_{s} p(s_t{=}s \mid x_t)\, p(x_1^{s^i} \mid x_t, s_t{=}s), which spreads probability mass over every token the mask could align to (here BB and CC). The gap targets gi(st)g^i(s_t) are ambiguous in the same way. We call this (see § 11.1 for its effect on the entropy of the predicted token distributions).

Generation

The generation proceeds through a tau-leaping [2] like procedure that approximately simulates the learned generative CTMC by superposing multiple independent generation decisions at each step. Specifically, given a time grid 0=t0<t1<⋯<tN=10=t_0 < t_1 < \dots < t_N = 1, the generation process proceeds by superposing the following independent decisions at each time step tnt_n:

  1. Sample Unmaskings: For each masked position i∈[ ⁣[ℓ(xt)] ⁣]i\in [\![\ell(x_t)]\!], sample the arrival count for each vocabulary item Ai,w∼Poisson(11−tnKθ,i(w∣xt)⋅τn)A_{i, w}\sim \mathop{\mathrm{Poisson}}(\frac{1}{1-t_n}K^{\theta,i}(w | x_t) \cdot \tau_n). If ∑wAi,w=1\sum_w A_{i, w} = 1, set xtix_t^i to the unique ww with Ai,w=1A_{i, w} = 1; otherwise leave the position as [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}}. We write SampleUnmask(x,K,t,τ)\mathop{\mathrm{SampleUnmask}}(x, K, t, \tau) for this operation applied to a sequence xx with token distributions KK at time tt and step size τ\tau.

  2. Sample Insertions: For each gap j∈[ ⁣[ℓ(xt)+1] ⁣]j\in [\![\ell(x_t)+1]\!] sample Ninj∼Poisson(11−tngθ,j(xt)⋅τn)N_{{{{\textnormal{in}}}}}^j\sim \mathop{\mathrm{Poisson}}(\tfrac{1}{1-t_n}g^{\theta,j}(x_t) \cdot \tau_n) and insert NinjN_{{{{\textnormal{in}}}}}^j masks in the jj-th gap of xtx_t (immediately left of xtjx_t^j), where τn=tn−tn−1\tau_n = t_n - t_{n-1} is the time step size. Insertion is not performed at the last time step tNt_N, because there will be no unmasking steps after it.

Key Limitation: The generation is iterative but does not have any kind of undo mechanism: once a token is unmasked, it cannot be changed even if it is incorrect, and similarly, once a [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}} is inserted, it cannot be removed even if it is deemed unnecessary later on. We call this .

\updeltaMDM

Incorporating corrections can overcome both the limitations mentioned in § 2. For this, we break down each generation step into two sub-steps: a proposal step, which is largely similar to the generation step in § 2.3, and a newly introduced correction step, which is used to undo actions from any of the earlier generation steps that are deemed incorrect or unnecessary. In this section, we describe the training and sampling procedures for \updeltaMDM that use proposal and correction steps.1

The \Expand and \Remove Operators

After insertions, all the positions on the right of the insertion point move further to the right by the number of inserted masks, and this movement compounds with more insertion points. Therefore, in practice, we need to record insertions and apply them in one vectorized operation. We describe the vectorized operation in detail here, which greatly simplifies the description of the training and sampling procedures later. Given current zt=(xt,st)z_t = (x_t, s_t), and insertion counts Nin=(Nin1,…,Ninℓ(xt)+1)N_{{{{\textnormal{in}}}}} = (N_{{{{\textnormal{in}}}}}^1, \dots, N_{{{{\textnormal{in}}}}}^{\ell(x_t)+1}), where NiniN_{{{{\textnormal{in}}}}}^i masks are inserted in the ii-th gap (i.e., immediately left of xtix_t^i), let π(i)≔i+∑k≤iNink\pi(i) \coloneqq i + \sum_{k \le i} N_{{{{\textnormal{in}}}}}^k be the position of the current ii-th cell after the insertions, for i∈[ ⁣[ℓ(xt)+1] ⁣]i\in[\![\ell(x_t)+1]\!]. Define \Expand(x_t, N_{\ensuremath{{{\textnormal{in}}}}}) to be the sequence of length ℓ(xt)+∑kNink\ell(x_t) + \sum_k N_{{{{\textnormal{in}}}}}^k with \Expand(x_t, N_{\ensuremath{{{\textnormal{in}}}}})^{\pi(i)} = x_t^i and [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}} in all remaining cells. Note that all NiniN_{{{{\textnormal{in}}}}}^i are defined in the coordinates of xtx_t, before any insertion. Conversely, for a sequence yy and a set of positions D⊆[ ⁣[ℓ(y)] ⁣]D\subseteq [\![\ell(y)]\!], \Remove(y, D) deletes the cells in DD and moves every cell on their right leftwards ( [E]{{{{\textnormal{\texttt{[E]}}}}}} is never in DD). With a slight abuse of notation, we reuse the same operator name when applied to sts_t, where it additionally assigns a value to every new cell instead of leaving it empty. Recall from § 2 that gtig_t^i is the number of ground-truth tokens missing in the ii-th gap of xtx_t. As shown in the figure below, the existing entries of sts_t move with their tokens through \Expand(s_t, N_{\ensuremath{{{\textnormal{in}}}}})^{\pi(i)} = s_t^i, and the jj-th new cell of the ii-th gap (j=1,…,Ninij = 1, \dots, N_{{{{\textnormal{in}}}}}^i, counted from the left) receives sti−1+js_t^{i-1} + j if j≤gtij \le g_t^i and −1-1 otherwise. Thus new cells are aligned, left to right, to the missing ground-truth positions, and surplus insertions (marked −1-1) have no ground-truth counterpart. In the figure, x1=ABCDEFx_1=\mathrm{ABCDEF}. xtx_t keeps AA, CC, and FF, aligned to positions 11, 33, and 66, and the second mask inserted before CC is marked −1-1 because that gap contains only the missing token BB. Arrows show the index movement under \Expand and the logit movement under \Remove. We write q_t \coloneqq \Expand(s_t, N_{\ensuremath{{{\textnormal{in}}}}}) for this alignment. Likewise, \Remove applied to per-position model outputs such as KθK^\theta carries each entry along with its token (below, y_t' = \Remove(y_t, D) and K' = \Remove(K^\theta, D)).

[
    x=1cm, y=1cm,
    tok/.style={draw, rounded corners=1.5pt, minimum width=0.5cm, minimum height=0.5cm, inner sep=0pt, font=\sffamily\bfseries\small, thick},
    plainbox/.style={tok, draw=black, fill=white},
    eosbox/.style={tok, draw=bs_grey_600, fill=bs_grey_600!12, font=\scriptsize},
    maskbox/.style={tok, draw=mask, fill=bs_magenta_200, text=mask},
    delbox/.style={tok, draw=drop, dashed, fill=bs_magenta_200, text=mask},
    mv/.style={-{Latex[length=1.5mm]}, thick, color=bs_grey_600},
    row/.style={anchor=east, font=\small},
    qrow/.style={anchor=east, font=\footnotesize, text=bs_grey_600},
    qv/.style={font=\footnotesize, text=bs_grey_600},
    qdel/.style={font=\footnotesize\bfseries, text=drop},
    steplbl/.style={font=\footnotesize, align=right, inner sep=1pt},
  ]
  \def\p{0.54}
  \def\yOne{1.15} \def\yOneq{0.70}
  \def\yT{0}    \def\yTq{-0.46}
  \def\yB{-1.5} \def\yBq{-1.95}

  %
  \begin{scope}[shift={(0,0)}]
    \node[row] at (0.55*\p, \yOne) {$x_1$};
    \foreach \l/\c in {A/1, B/2, C/3, D/4, E/5, F/6} {
      \node[plainbox] at (\c*\p, \yOne) {\l};
      \node[qv] at (\c*\p, \yOneq) {$\c$};
    }
    \node[eosbox] at (7*\p, \yOne) {\eos};
    \node[qv] at (7*\p, \yOneq) {$7$};
    \foreach \l/\c/\q in {A/1/1, C/2/3, F/3/6} {
      \node[plainbox] at (\c*\p, \yT) {\l};
      \node[qv] at (\c*\p, \yTq) {$\q$};
    }
    \node[eosbox] at (4*\p, \yT) {\eos};
    \node[qv] at (4*\p, \yTq) {$7$};
    \node[row]  at (0.55*\p, \yT)  {$x_t$};
    \node[qrow] at (0.55*\p, \yTq) {$s_t$};
    \foreach \l/\c in {A/1, C/4, F/7} {
      \node[plainbox] at (\c*\p, \yB) {\l};
    }
    \node[eosbox] at (8*\p, \yB) {\eos};
    \foreach \c in {2,5,6} {
      \node[maskbox] at (\c*\p, \yB) {\mask};
    }
    \node[delbox] at (3*\p, \yB) {\mask};
    \node[row]  at (0.55*\p, \yB)  {$x_t'$};
    \node[steplbl, anchor=east] at (0.15*\p, 0.5*\yTq+0.5*\yB) {$\Expand(\cdot,N_{\ins})$\\$N_{\ins}=(0,2,2,0)$};
    %
    \foreach \c/\q in {1/1, 2/2, 4/3, 5/4, 6/5, 7/6, 8/7}
      \node[qv] at (\c*\p, \yBq) {$\q$};
    \node[qdel] at (3*\p, \yBq) {$-1$};
    \node[qrow] at (0.55*\p, \yBq) {$q_t$};
    \foreach \a/\b in {1/1, 2/4, 3/7, 4/8}
      \draw[mv] (\a*\p, \yTq-0.17) -- (\b*\p, \yB+0.31);
  \end{scope}

  %
  \begin{scope}[shift={(5.15,0)}]
    \foreach \l/\c/\q in {A/1/1, C/4/4, F/7/7} {
      \node[plainbox] at (\c*\p, \yT) {\l};
      \node[qv] at (\c*\p, \yTq) {$K_\q$};
    }
    \node[eosbox] at (8*\p, \yT) {\eos};
    \node[qv] at (8*\p, \yTq) {$K_8$};
    \foreach \c in {2,5,6} {
      \node[maskbox] at (\c*\p, \yT) {\mask};
      \node[qv] at (\c*\p, \yTq) {$K_\c$};
    }
    \node[delbox] at (3*\p, \yT) {\mask};
    \node[qv] at (3*\p, \yTq) {$K_3$};
    \node[row]  at (0.55*\p, \yT)  {$y_t$};
    \node[qrow] at (0.55*\p, \yTq) {$K^\theta$};
    \foreach \l/\c/\q in {A/1/1, C/3/4, F/6/7} {
      \node[plainbox] at (\c*\p, \yB) {\l};
      \node[qv] at (\c*\p, \yBq) {$K_\q$};
    }
    \node[eosbox] at (7*\p, \yB) {\eos};
    \node[qv] at (7*\p, \yBq) {$K_8$};
    \foreach \c/\q in {2/2, 4/5, 5/6} {
      \node[maskbox] at (\c*\p, \yB) {\mask};
      \node[qv] at (\c*\p, \yBq) {$K_\q$};
    }
    \node[row]  at (0.55*\p, \yB)  {$y_t'$};
    \node[steplbl, anchor=west, align=left] at (8.55*\p, 0.5*\yTq+0.5*\yB) {$\Remove(\cdot,D)$\\$D=\{3\}$};
    \node[qrow] at (0.55*\p, \yBq) {$K'$};
    \foreach \a/\b in {1/1, 2/2, 4/3, 5/4, 6/5, 7/6, 8/7}
      \draw[mv] (\a*\p, \yTq-0.17) -- (\b*\p, \yB+0.31);
    \draw[thick, color=drop] (3*\p-0.1, \yTq-0.32) -- ++(0.2,-0.2);
    \draw[thick, color=drop] (3*\p-0.1, \yTq-0.52) -- ++(0.2,0.2);
  \end{scope}

Training

Each training step for \ensuremath{\updelta}\textsc{MDM}{} consists of three sub-steps that work sequentially. Figure 2 depicts the training procedure for \updeltaMDM.

Proposal training. The proposal training step is identical to vanilla insertion-based masked diffusion model as described in § 2.2.

Sampling from the proposal. The goal of this sub-step is to simulate an aggressive proposal, which the correction step can use as the input and learn to correct. For this, we replace the standard τ\tau-leaping sampler step (see § 2.3) with the following:

  1. Sample Aggressive Unmaskings: Instead of drawing Poisson arrivals over a step of size τ\tau, which unmask only a random subset of the masks, we unmask every masked position in the current xtx_t at once by greedy decoding, x~ti←arg maxwKθ,i(w∣xt)\tilde x_t^i \gets \mathop{\mathrm{arg\,max}}_w K^{\theta,i}(w \mid x_t) for all ii with xti=[M]x_t^i={{\color{mask}{{\textnormal{\texttt{[M]}}}}}}. Addtionally, we also allow already unmasked positions of xtx_t to also be substituted using the same argmax operation. This is necessary to provide strong training signal for substitutions in the correction step.

  2. Sample Aggressive Insertions: We sample an insertion fraction ρ∼Uniform(0,1)\rho\sim\mathop{\mathrm{Uniform}}(0,1) per sequence and, for every gap ii of xtx_t, an insertion count Nini∼Poisson(ρ gθ,i(xt))N_{{{{\textnormal{in}}}}}^i\sim\mathop{\mathrm{Poisson}}(\rho\, g^{\theta,i}(x_t)). Since the insertion rate in § 2.3 is τn1−t gθ,i\tfrac{\tau_n}{1-t}\,g^{\theta,i}, this corresponds to a single leap of size τ=ρ(1−t)\tau=\rho(1-t), which ranges from almost no insertions (ρ→0\rho\to 0) to inserting the entire predicted remaining gap length in one step (ρ=1\rho=1). Thus ρ\rho is the fraction of the predicted remaining gap that is inserted in one step, and covering (0,1)(0,1) exposes the corrector to every per-step insertion fraction that the sampler can produce (see § 3.3).

Therefore, after this step, only the newly inserted masks remain in the proposal sequence.

Correction training. Let y_t \coloneqq \Expand(\tilde x_t, N_{\ensuremath{{{\textnormal{in}}}}}) be the proposal from . We feed it back into the same network KθK^\theta and train the network to correct it. Note that yty_t may be low probability under pt(⋅∣x1)p_t(\cdot | x_1) for any time because all masks of xtx_t have been filled, as if tt were close to 11, while the number of new masks depends on the random fraction ρ\rho. The aggressive proposal therefore destroys the time information, and we have to make KθK^\theta time-blind. With that the same network serves as both proposer and corrector. Because x~t\tilde x_t is obtained by argmax and NinN_{{{{\textnormal{in}}}}} by sampling, no gradient flows through the construction of yty_t, which serves only as an on-policy input. The targets come from the alignment q_t = \Expand(s_t, N_{\ensuremath{{{\textnormal{in}}}}}) as shown in alg:vld_training. Every cell with qti≠−1q_t^i \neq -1 has the ground-truth counterpart x1qtix_1^{q_t^i}, and every cell with qti=−1q_t^i = -1 is a surplus insertion whose target is the deletion token [DEL]{{\color{drop}{{\textnormal{\texttt{[DEL]}}}}}}. In other words, within each gap, the new masks are matched from left to right to the missing ground-truth tokens, and the excess masks at the right end of the gap are deleted. Note that many other alignments are valid, but we fix this one for simplicity. The total correction loss is the sum of a substitution and deletion terms:

Lsubs(θ)=E[11−t∑i:qti≠−1−log⁡Kθ,i(x1qti ∣yt)],   Ldel(θ)=E[11−t∑i:qti=−1−log⁡Kθ,i([DEL] ∣yt)].\begin{equation} \mathcal{L}_{\text{subs}}(\theta) = \mathop{\mathbb{E}}\Big[ \tfrac{1}{1-t}\hspace{-10pt} \sum_{i: q_t^i \neq -1}\hspace{-8pt} -\log K^{\theta, i}(x_1^{q_t^i}\,| y_t) \Big],~~~ \mathcal{L}_{\text{del}}(\theta) = \mathop{\mathbb{E}}\Big[ \tfrac{1}{1-t}\hspace{-10pt} \sum_{i: q_t^i = -1}\hspace{-8pt} -\log K^{\theta, i}({{\color{drop}{{\textnormal{\texttt{[DEL]}}}}}}\,| y_t) \Big]. \tag*{(3)} \end{equation}

Unlike Lum\mathcal L_{{{\color{unmask}\textnormal{um}}}}, which only covers masked positions, Lsubs\mathcal L_{\text{subs}} covers every cell of yty_t that has a ground-truth counterpart. The model therefore learns to replace wrong argmax fills, keep correct tokens (including the ones already unmasked in xtx_t), and unmask the new masks that align to ground truth. Ldel\mathcal L_{\text{del}} teaches it to delete masks that have no ground-truth counterpart. The full training objective is L=Lum+Lin+Lsubs+Ldel\mathcal L = \mathcal L_{{{\color{unmask}\textnormal{um}}}} + \mathcal L_{{{{\textnormal{in}}}}} + \mathcal L_{\text{subs}} + \mathcal L_{\text{del}}, where each term is normalized per-token across the whole batch.


height 0.8pt



height 0.8pt

Figure 2Vector (PDF)

Figure 2. \updeltaMDM Training Step. Left: alg:vld_training; right: toy example. The three shaded blocks in the algorithm correspond to stages 1–3 of the illustration.  Proposal training as described in § 2.2.  Sample proposal by filling every position with the argmax of KθK^{\theta}, including tokens already unmasked in xtx_t, and inserting from a Poisson count with mean between 0 and gθ,i(xt)g^{\theta, i}(x_t) for each gap. All counts are drawn in the coordinates of xtx_t, and inserting them shifts every later token to the right (\Expand, § 3.1). In the example the argmax replaces the already-unmasked AA with ZZ, and the correction target at that cell remains AA.  Correction training by aligning yty_t to x1x_1 via q_t = \Expand(s_t, N_{\ensuremath{{{\textnormal{in}}}}}) (§ 3.1): each new cell is aligned to a missing ground-truth position, or gets −1-1 and is deleted by predicting [DEL]{\color{drop}{{\textnormal{\texttt{[DEL]}}}}}. Then we substitute tokens (Lsubs\mathcal L_{\mathrm{subs}}), fill the leftmost new [M]{\color{mask}{{\textnormal{\texttt{[M]}}}}}s, and delete the excess [M]{\color{mask}{{\textnormal{\texttt{[M]}}}}}s from the right (Ldel\mathcal L_{\mathrm{del}}).

Generation

For generation, we interleave proposal and correction steps in an alternating fashion. The sampler starts from the empty sequence x0=∅x_0=\emptyset and applies the proposal-correction step described in alg:vld_sampling over a time grid 0=t0<⋯<tn=10=t_0<\dots<t_n=1, returning xnx_n. The first forward pass, on xtx_t, gives both the greedy fill and the insertion counts (lines 2–3). As in training, the greedy fill x~t\tilde x_t takes the argmax over the vocabulary at every position of xtx_t, and the counts NiniN_{{{{\textnormal{in}}}}}^i are sampled from the predicted gap lengths gθ,i(xt)g^{\theta,i}(x_t). Unlike the training fraction ρ\rho, the insertion scale λ\lambda multiplies the τ\tau-leaping rate, Nini∼Poisson(λτ1−t gθ,i(xt))N_{{{{\textnormal{in}}}}}^i\sim\mathop{\mathrm{Poisson}}(\tfrac{\lambda\tau}{1-t}\,g^{\theta,i}(x_t)), so λ=1\lambda=1 recovers the standard sampler of § 2.3 and λ>1\lambda>1 makes every step more aggressive. The same counts expand two sequences (line 4): x_t' = \Expand(x_t, N_{\ensuremath{{{\textnormal{in}}}}}) is the sequence being edited and still contains the masks of xtx_t, while the proposal y_t = \Expand(\tilde x_t, N_{\ensuremath{{{\textnormal{in}}}}}) has masks only at the newly inserted cells. Note that the greedy fill is not written into xt′x_t', it only serves as a proposal for the corrector. Then the corrector (alg:vld_correction) performs a second forward pass, on yty_t, and uses Kθ(⋅∣yt)K^\theta(\cdot\mid y_t) to substitute incorrect tokens, delete unnecessary newly inserted masks, and provide the unmasking distributions for all remaining masks. For substitutions (line 3), we use argmax over the vocabulary items from Kθ(⋅∣yt)K^\theta(\cdot\mid y_t) at the positions U={i∣xt′i≠[M]}\mathcal U=\{i \mid x_t'^i \ne {{\color{mask}{{\textnormal{\texttt{[M]}}}}}}\}, i.e., only at tokens that were already unmasked in xtx_t. For deletions (line 1), we consider only the newly inserted masks Mnew={i∣yti=[M]}\mathcal M_{\text{new}}=\{i \mid y_t^i = {{\color{mask}{{\textnormal{\texttt{[M]}}}}}}\}, and if a deletion event is sampled for any of these positions, we remove the position and shift every later cell to the left along with the corresponding logits (lines 4–5). Masks inherited from xtx_t are neither substituted nor deleted. The output of the correction is the new sequence xt+τx_{t+\tau} and the updated token probabilities \hat K = \Remove(K^\theta(\cdot\mid y_t), \mathcal M_{\text{del}}). The unmasking of all remaining masks in xt+τx_{t+\tau}, both inherited and newly inserted, is then performed based on K^\hat K with a chosen sampling function. On steps where correction is skipped, xt+τ=xt′x_{t+\tau}=x_t' and the logits are carried through the same shift, \Expand(K^\theta(\cdot\mid x_t),N_{\ensuremath{{{\textnormal{in}}}}}) as shown in line 9 of alg:vld_sampling. In this case, the newly inserted cells have no logits yet and are therefore not unmasked in that step. Both proposal and correction steps are counted towards the total number of forward passes. Unless stated otherwise, we set apply_correction\textit{apply\_correction} to true at every step, i.e., one correction step follows each proposal step, giving T/2T/2 proposal and T/2T/2 correction steps. Note that since the model is time-blind, the network never sees tt. It enters only through the 11−t\tfrac{1}{1-t} factor in the Poisson rates for insertions, deletions, and unmasking (SampleUnmask\mathop{\mathrm{SampleUnmask}}), and through the same factor in the training losses.


height 0.8pt



height 0.8pt


height 0.8pt



height 0.8pt

Figure 3.

Experiments

Setup

All models use a transformer backbone with rotary positional embeddings, pre-layernorm and are trained from scratch. 2 For masked diffusion we use the time-agnostic version with unweighted cross-entropy loss [32] as it has been shown to work better than time-conditioned MDLM that uses ELBO [20]. Moreover, we pre-train MDM for variable length sequences using padded sequences instead of packed sequences for a fair comparison. For vanilla insertion-based masked diffusion we reimplement FlexMDM [6], which is not time-blind and uses adaptive layer normalization conditioned on a time embedding. In order to obtain time-blind \updeltaMDM, we pin the time embedding to a constant value of 1, but keep the same architecture as FlexMDM. 3 Since \updeltaMDM uses two forward passes per training step, we compare against baselines that are trained for twice the number of total training steps at the same global batch size. At inference, unless stated otherwise, \updeltaMDM applies one correction step after every proposal step with both steps counted towards the sampling budget TT. We conduct comprehensive evaluation on three different types of tasks: controlled complexity synthetic planning, high-diversity unconditional text generation, and low-diversity reasoning using code generation. The rest of this section discusses the results on the text generation task with results on synthetic star-graph planning task provided in § 10.1.

Unconditional Generation on OpenWebText

We pretrain MDM, FlexMDM and \updeltaMDM on a preprocessed version of OpenWebText (OWT) dataset tokenized using the GPT-2 tokenizer, where we remove documents that are longer than 1024 tokens, and pad the remaining documents to 1024 tokens creating a variable length corpus [17]. \updeltaMDM is trained for 400k steps with global batch size of 512, while MDM and FlexMDM are trained for 800k steps. We additionally compare against the insertion language models ILM [16] and DILM-S [17], trained on OWT for 800k steps, which we evaluate using the implementation and checkpoints provided by [17]. We generate 1000 samples per setting with nucleus sampling applied to all methods with p=0.9p=0.9 and report generation perplexity under GPT-2 Large and as well as token entropy across total sampling step budgets. For \updeltaMDM, we use the insertion scale λ=0.90\lambda=0.90 in Table 1.

As shown in Table 1, \updeltaMDM achieves lower generative perplexity compared to FlexMDM at all budgets except for T=32T=32. Interestingly, we observe that \updeltaMDM keeps improving in quality at a higher rate compared to FlexMDM as the inference budget increases (see Figure 1 bottom right). Specifically, at T=1024T=1024, \updeltaMDM halves the generative perplexity of FlexMDM (20.35 vs. 40.37) and reduces that of MDM by 47% (20.35 vs. 38.16). Conversely, \updeltaMDM at 128 sampling steps obtains lower Gen. PPL than both FlexMDM and MDM at 1024 steps, an 8x reduction in sampling steps. \updeltaMDM also obtains lower Gen. PPL than the insertion language models ILM [16] and DILM-S [17] at every budget they report, while keeping a much higher token entropy than DILM-S (4.60–4.72 vs. 3.45–3.79). The token entropy for \updeltaMDM is generally lower than that of FlexMDM but it remains stable across all budgets. 4 Cross-budget plots of token entropy against generative perplexity are in § 11.3. fig:genppl_vs_insertion_scale shows the effect of the insertion scale λ\lambda at inference: for every budget, Gen. PPL is lowest for moderate scales (λ≈1.1\lambda \approx 1.1–1.251.25) and rises sharply for λ≥1.5\lambda \geq 1.5, where the generated sequences approach the maximum length. We analyze the length of the generated sequences in § 11.6.

ModelGen. PPL (())Entropy (())
StepsTT3264128256512102432641282565121024
MDM230.9687.4854.1845.0840.1038.163.333.593.984.324.564.71
ILM†^\dagger--222.1953.7051.2149.74--4.274.424.304.42
DILM-S†^\dagger--36.1029.9123.2021.21--3.453.613.713.79
FlexMDM73.8057.5948.8343.8142.8040.374.834.874.894.884.884.88
75.2346.7632.8525.9422.8920.354.474.554.604.644.694.72

Table 1. Generative perplexity and token entropy under GPT-2 Large at different sampling budgets TT (network forward passes). \ensuremath{\updelta}MDM{} uses insertion scale λ=0.90\lambda=0.90 and one correction step per proposal step from the start, both counted in TT. †^\daggerILM [16] and DILM-S [17], replicated from the implementation and checkpoints provided by [17].

Figure 4. GSM8K pass@1 of \updeltaMDM vs. insertion scale λ\lambda at T=250T{=}250 (other budgets in § 11.5).

Conditional Generation on TinyGSM

scratch on TinyGSM  [10] dataset containing 11.8M grade school math problems converted to solutions in Python. This dataset is qualitatively different from OWT in several ways: (1) it is a conditional generation task, where there is an input question, and (2) since the solutions are Python code, the output sequences are much more structured and show less diversity. We use the same model architectures and training budgets as we do for OWT pretraining. Once trained, we evaluate the models on the test split of GSM8K  [1] dataset containing 1.32K problems and report the pass@1 score by comparing exact numerical answers.

ModelGSM8K pass@1 (%, ())
StepsTT12525050010001500
MDM37.38\textbf{37.38}40.71\textbf{40.71}40.3340.3340.6440.6441.0941.09
FlexMDM8.728.7220.7720.7731.7731.7740.4140.4141.3941.39
20.6220.6233.0633.0642.23\textbf{42.23}46.85\textbf{46.85}47.01\textbf{47.01}

For this task, we use greedy decoding, i.e., we pick the token with the highest probability to fill the selected mask position for all the models. For \updeltaMDM, we use the insertion scale λ=1.75\lambda=1.75. As seen in tab:gsm8k_pass@1, \updeltaMDM outperforms FlexMDM at every budget, with the largest gap at low budgets, where \updeltaMDM matches FlexMDM’s accuracy with half the steps. MDM is the strongest model at the lowest budgets (T≤250T \le 250), but its accuracy plateaus around 40–41%, and \updeltaMDM overtakes it from T=500T=500 onward.

Analysis

In this section, we provide a more detailed analysis of the corrections performed by \updeltaMDM.

When do corrections happen and how frequently? We measure correction intensity as the fraction of eligible positions that are substituted or deleted at each step, and plot it against normalized generation time (fig:owt_correction_intensity_density,fig:gsm8k_correction_intensity_density, § 11.4). On both OWT and GSM8K, substitutions peak early and deletions dominate near the end. Early in generation the sequence is short and many tokens were predicted with little context, so replacing them in place is the natural fix. Towards the end, most of the sequence is already fixed, and errors tend to show up as excessive addition of new masks.

What happens when we increase the aggressiveness of insertions? We can increase the aggressiveness of insertions by increasing the insertion scale λ\lambda at inference time. Note that λ>1\lambda>1 is not an extrapolation beyond training: λ\lambda scales the per-step leap, and for all λ≤2\lambda \leq 2 the fraction of the predicted gap inserted per step stays within the range (0,1)(0,1) seen during training (§ 3.3). As shown in fig:genppl_vs_insertion_scale, for unconditional generation, there is a diminishing return in quality as we increase the insertion scale especially at higher inference budgets. At small budgets (T≤64T \leq 64), Gen. PPL keeps improving up to λ=1.25\lambda{=}1.25 and stays flat at λ=1.5\lambda{=}1.5, whereas for T≥256T \geq 256 it is lowest at λ≈1.1\lambda \approx 1.1–1.251.25 and rises sharply beyond. On GSM8K, we additionally vary the correction offset, i.e., the number of prediction steps taken before correction steps begin, which is 00 in all other experiments (Figure 4, and § 11.5 for T∈{500,1000}T \in \{500, 1000\}). When correction is applied from the start (offset 00), accuracy increases with λ\lambda up to λ=2\lambda{=}2 at T=250T{=}250 and up to λ=1.75\lambda{=}1.75 at T∈{500,1000}T \in \{500, 1000\}. In contrast, with a late correction start, accuracy peaks at λ=1.5\lambda{=}1.5 and then declines, so the gap to offset 00 widens as insertions become more aggressive, reaching roughly 1010 points or more at the largest λ\lambda for every budget. At λ=1\lambda{=}1 this ordering is reversed for T∈{250,500}T \in \{250, 500\}, where a late start is slightly better, i.e., early corrections pay off mainly when the proposal is aggressive enough to introduce errors. Larger budgets raise accuracy across all settings, but do not remove the need for early correction: aggressive insertion pays off most when the model has enough correction steps to fix the resulting mistakes.

What is the impact of the correction step on predictive entropy? The correction step performs a second forward pass over the sequence after the aggressive proposal. We plot the average predictive entropy at the positions that are masked in xtx_t, comparing Kθ(⋅∣xt)K^\theta(\cdot\mid x_t) from the proposal pass with Kθ(⋅∣yt)K^\theta(\cdot\mid y_t) from the correction pass, where these positions hold the greedy proposal tokens (Figure 6 in § 11.1), and find that entropy is generally lower after the correction forward pass. Since the greedy fill places a concrete token at each of these positions, the proposal tends to favor some of the plausible alignments over others, and conditioning on it contributes to reducing the alignment ambiguity that inflates FlexMDM’s entropy at mask slots (fig:owt_entropy). We hypothesize that these sharper predictions are what allow \updeltaMDM to unmask more tokens per step, consistent with the budget curves in tab:owt_pretraining_metrics,tab:gsm8k_pass@1.

Related Work

There have been serveral approaches proposed for incorporating corrections in fixed-length MDMs. [26] propose re-masking decoded tokens based on decoding confidence. More recent works such as [7, 3, 12] add additional heads over pretrained MDMs to estimate token quality in a partially masked sequence, where lower-quality tokens are re-masked for the next unmasking step. Supervision for the correction heads is obtained by randomly replacing correct tokens with other tokens in the vocabulary [3], sampling from the model’s own token distribution [7], or introducing human-injected synthetic errors [4]. Pretrained MDMs are then fine-tuned to optimize the correction loss with MDM loss regularization. [21] propose alternating unmasking and correction steps similar to our approach. However, they limit the corrections to substitutions only, and don’t consider length changing operations. [25] uses a mixed noise schedule with both uniform vocabulary and masked noise, thereby enabling the model to perform token flips. [31] also correct decoded tokens but require architectural changes to the denoising model, thereby necessitating retraining. While much of the prior work on correction focuses on fixed-length MDMs, few approaches address self-correction in variable-length settings. [27] introduces length control in MDMs using custom expansion and deletion operations that adaptively insert and remove masks. However, they focus on code infilling benchmarks and do not consider substitutions.

Limitations

The corrector is trained on a single step of aggressive proposal. At inference, proposals are built on the model’s own earlier outputs, so errors can compound over many proposal-correction rounds and produce states that were not seen in training resulting in exposure bias. Unrolling several rounds during training or fully on-policy training could address this, but it would considerably more complex. The corrections can be made more expressive by allowing deletion of visible tokens, however, that would cause ambiguous supervision in the current framework. Further scaling and adaptation study is left as future work.

Conclusion and Outlook

This work introduces \updeltaMDM, a variable-length masked diffusion model with insertion, deletion, and substitution actions. It learns the correction operations from its own aggressive proposals without requiring any auxiliary model. \updeltaMDM Pareto-dominates FlexMDM on the speed–quality trade-off, exhibits better scaling with inference budget across unconditional as well as conditional text generation tasks. More broadly, our results hint at a division of labor. The discrete diffusion framework, with its fixed noising process and simple training objective, provides a stable recipe for training from scratch. However, the gains of \updeltaMDM come from departing from it in two ways: the model is time-blind, and it is trained on corruptions produced by its own proposals. Together, these make each sampling step behave less like integrating a prescribed continuous-time process and more like repeatedly applying a single learned refinement operator. This suggests that adapting pretrained diffusion models with such self-correction objectives, in the spirit of fixed-point iteration, could be a promising route to faster and higher-quality generation.

AI use statement

In this work, we used generative AI tools for some parts of the model implementation and analysis code. Additionally, we used generative AI tools for formatting some of the figures and tables, and for polishing the writing of some parts of the manuscript. The two main authors have reviewed all AI generated code as well as content, and all the authors take full responsibility for the final content of this work, including text, claims and artifacts produced with the aid of generative AI.

Reproducibility statement

We provide complete details of our core algorithm in § 3. § 4 describes the datasets used, along with the details of preprocessing. The model architecture is also described in § 4, with key hyperparameters listed in app:experimental_details. We implement all the baselines described in § 4 using the xLM framework for non-autoregressive language modeling [14]. Anonymized source code is available at https://anonymous.4open.science/r/DeltaMDM. The trained model checkpoints and logged training loss curves on Weights and Biases will be made publicly available upon acceptance.

.tocmtappendix

Summary of Notation

Table 2 summarizes the notation used throughout the paper.

NotationDescription
Sequences and spaces
[ ⁣[n] ⁣][\![n]\!]The set {1,2,…,n}\{1, 2, \ldots, n\}
\sVVocabulary of tokens, including the mask token [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}}
[M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}}Mask token
[D]{{\color{drop}{{\textnormal{\texttt{[D]}}}}}}Marker for a dropped position; not part of \sV and never seen by the model
[DEL]{{\color{drop}{{\textnormal{\texttt{[DEL]}}}}}}Deletion token; the correction target for surplus inserted masks
LLMaximum sequence length
\sXSpace of variable length sequences, \sX = \bigcup_{k=1}^L \sV^k
\sZSpace of partial sequences with positions, \sZ = \bigcup_{k\in [\![L]\!]} \sV^k \times \sS_{k}, where \sS_{k} \coloneqq \{(s^1, \dots, s^k)\in [\![L]\!]^k \mid s^1 < \dots < s^k\}
\bar \sZ, fcontract{f_{\text{contract}}}\bar \sZ = (\sV\cup \{\ensuremath{{\color{drop}{{\textnormal{\texttt{[D]}}}}}}\})^{L}, and the isomorphism \ensuremath{f_{\text{contract}}}: \bar \sZ \to \sZ that removes the [D]{{\color{drop}{{\textnormal{\texttt{[D]}}}}}} markers from zˉ\bar z and records the positions of the remaining tokens
ℓ(x)\ell(x)Length of the sequence xx
xix^iii-th token of the sequence xx (superscripts index positions)
Noising and training
p1=pdatap_1 = p_{\text{data}}, p0p_0Data distribution; initial distribution (a Dirac delta on the empty sequence)
ttTime, t∈[0,1]t \in [0, 1]
x1x_1, xtx_tClean sequence; noisy partial sequence at time tt
zˉt\bar z_t, zt=(xt,st)z_t = (x_t, s_t)Noisy state in \bar \sZ ((1)) and its contraction fcontract(zˉt){f_{\text{contract}}}(\bar z_t)
sts_tPositions in x1x_1 of the tokens of xtx_t
\Tins^i, \Tumask^iInsertion and unmasking times of the ii-th position
gtig_t^iNumber of ground-truth tokens missing in the ii-th gap of xtx_t, gti=sti−sti−1−1g_t^i = s_t^i - s_t^{i-1} - 1
Lum\mathcal L_{{{\color{unmask}\textnormal{um}}}}, Lin\mathcal L_{{{{\textnormal{in}}}}}Unmasking and insertion losses ((2))
Lsubs\mathcal L_{\text{subs}}, Ldel\mathcal L_{\text{del}}Substitution and deletion losses ((3))
D(a,b)D(a, b)Scalar Bregman divergence, D(a,b)=alog⁡ab−(a−b)D(a, b) = a\log\frac{a}{b} - (a - b)
Model
θ\thetaModel parameters
Kθ,i(⋅∣x)K^{\theta, i}(\cdot \mid x)Predicted token distribution at the ii-th position of xx, over \sV\cup \{\ensuremath{{\color{drop}{{\textnormal{\texttt{[DEL]}}}}}}\}
gθ,i(x)g^{\theta, i}(x)Predicted length of the ii-th gap of xx
Proposal, correction, and sampling
Nin=(Nin1,… )N_{{{{\textnormal{in}}}}} = (N_{{{{\textnormal{in}}}}}^1, \dots)Number of masks inserted in each gap, in the coordinates of xtx_t
ρ\rhoTraining insertion fraction, ρ∼Uniform(0,1)\rho \sim \mathop{\mathrm{Uniform}}(0, 1); the fraction of the predicted remaining gap inserted in one step
λ\lambdaInference insertion scale multiplying the τ\tau-leaping insertion rate; each step inserts the fraction ρt=λτ1−t≤λ/2\rho_t = \tfrac{\lambda\tau}{1-t} \leq \lambda/2
\Expand(\cdot, N_{\ensuremath{{{\textnormal{in}}}}}), π(i)\pi(i)Inserts masks into the gaps, shifting later cells to the right; π(i)\pi(i) is the new index of cell ii (§ 3.1)
\Remove(\cdot, D)Deletes the cells in DD, shifting later cells to the left
x~t\tilde x_txtx_t with every [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}} filled by the argmax of KθK^{\theta}
xt′x_t'xtx_t after insertions, x_t' = \Expand(x_t, N_{\ensuremath{{{\textnormal{in}}}}})
yty_tProposal given to the corrector, y_t = \Expand(\tilde x_t, N_{\ensuremath{{{\textnormal{in}}}}})
qtq_tAlignment of yty_t to x1x_1, q_t = \Expand(s_t, N_{\ensuremath{{{\textnormal{in}}}}}); qti=−1q_t^i = -1 marks a surplus mask with target [DEL]{{\color{drop}{{\textnormal{\texttt{[DEL]}}}}}}
U\mathcal U, Mnew\mathcal M_{\text{new}}, Mdel\mathcal M_{\text{del}}Unmasked positions; newly inserted masks; new masks selected for deletion
NdeliN_{\text{del}}^iDeletion arrival count at position ii
0=t0<⋯<tN=10 = t_0 < \dots < t_N = 1, τ\tauSampling time grid; step size
SampleUnmask(x,K,t,τ)\mathop{\mathrm{SampleUnmask}}(x, K, t, \tau)τ\tau-leaping unmasking step (§ 2.3)

Table 2. Summary of notation used throughout the paper.

Experimental Details

All trained models use the architecture and optimization settings in Table 3. \updeltaMDM is trained for 400k steps, while MDM and FlexMDM are trained for 800k steps. ILM [16] and DILM-S [17] are evaluated from the implementation and 800k step checkpoints provided by [17]. OpenWebText sequences are padded to length 1024, and TinyGSM sequences use length 512. For the main results (tab:owt_pretraining_metrics,tab:gsm8k_pass@1), \updeltaMDM uses the insertion scale λ=0.90\lambda=0.90 on OpenWebText and λ=1.75\lambda=1.75 on TinyGSM. Correction is applied after every proposal step from the first step (offset 00), and both proposal and correction steps count towards the budget TT.

HyperparameterValue
Layers1212
Hidden size768768
Attention heads1212
Feed-forward width30723072
Rotary dimension6464
Dropout0.10.1
ActivationReLU
Non-embedding parameters≈87\approx 87M
OptimizerAdamW
Learning rate10−410^{-4}
Weight decay0.010.01
ScheduleConstant with linear warmup
Warmup steps2,0002{,}000
Global batch size512512
Gradient clipping11
Precisionbfloat16 mixed

Table 3. Architecture and optimization settings shared by all trained models. The parameter count is the transformer body and excludes token embeddings.

Additional Tasks

Synthetic Planning: Star Graphs

Given a start node and a target node, the model must generate the unique path on a star-shaped graph. Following [16], we use three splits (easy, medium, hard) with increasing difficulty in terms of variable arm lengths and non-junction start nodes. The model input is a flattened edge list followed by the start node, target node, and EOS token. We use an insertion scale factor of 22 (the best value from a sweep over II) and report exact match (EM) at sampling budget T=500T{=}500 (Table 4). MDM uses confidence based decoding with the top probability value for choosing unmasking positions in the sequence during sampling. FlexMDM uses the same inference procedure detailed in [6].

ModelStareasy_{\text{easy}} (↑\uparrow)Starmedium_{\text{medium}} (↑\uparrow)Starhard_{\text{hard}} (↑\uparrow)
MDM10010074.38
FlexMDM92.0093.137.27
Ours98.7098.6096.47

Table 4. Star-graph exact match (%) at T=500T{=}500 sampling steps.

Figure 5. Starhard_{\text{hard}} exact match (↑\uparrow) vs. sampling budget for \updeltaMDM and FlexMDM at T∈{32,64,128,256,512}T \in \{32,64,128,256,512\}.

Additional Analysis

Multiple alignment problem

fig:owt_entropy shows the entropy of the predicted token distribution at masked positions as a function of time tt on OWT for FlexMDM and MDM. Due to the multiple alignments problem (§ 2.2), the supervision for a [M]{{\color{mask}{{\textnormal{\texttt{[M]}}}}}} in FlexMDM is spread across several candidate positions of x1x_1, resulting in much higher entropy than MDM for most of the generation. Figure 6 shows the same quantity for \updeltaMDM at sampling budget T=512T{=}512, before and after the correction step.

Figure 6. Entropy of the predicted token distribution at masked positions vs. time tt on OWT for \updeltaMDM at T=512T{=}512, before and after correction.

Time-blindness

Table 5 compares FlexMDM with time-blind FlexMDM on GSM8K with both models trained for 800k steps. As seen here, removing time from the model’s input makes only a small difference in performance: the gap is within 0.250.25 points at T≤500T\le 500 and about 2.32.3 points at T=1000T=1000.

Model2505001000
FlexMDM20.7720.7731.7731.7740.4140.41
FlexMDM (time-blind)21.0021.0031.8431.8438.1338.13

Table 5. GSM8K test pass@1 (%) vs. sampling budget TT for FlexMDM and time-blind FlexMDM, both trained for 800k steps.

Entropy vs. generation perplexity across sampling budgets

Figure fig:entropy_vs_genppl in the main text reports entropy vs. Gen. PPL at T=512T{=}512. Here we include the corresponding plots for the remaining budgets T∈{32,64,128,256,1024}T \in \{32,64,128,256,1024\}.

(a) T=32T{=}32

(b) T=64T{=}64

(c) T=128T{=}128

(d) T=256T{=}256

(e) T=512T{=}512

(f) T=1024T{=}1024

Figure 7. Entropy vs. generation perplexity (GPT-2 Large) on OWT for nucleus sampling with p∈{0.9,0.95,0.99,1}p \in \{0.9, 0.95, 0.99, 1\} at the remaining sampling budgets.

How are corrections distributed?

fig:owt_correction_intensity_density,fig:gsm8k_correction_intensity_density show the distribution of correction intensity over normalized time. The intensity is defined as the percentage of eligible positions that are corrected (substituted or deleted) at that time step. Each cell counts how often a given intensity occurs at that time across all the generations. As shown in the figures, the substitutions peak early in the generation process while the deletions increase towards the end. This intuitively makes sense because isolated substitutions are difficult to make towards the end of the generation when most of the sequence is already generated. Moreover, early on there isn’t much need for deletions because the sequence is still short.

(a) Substitutions, T=128T{=}128

(b) Deletions, T=128T{=}128

(c) Substitutions, T=512T{=}512

(d) Deletions, T=512T{=}512

Figure 8. Distribution of substitution and deletion intensity over normalized time for \updeltaMDM on OWT.

(a) Substitutions, T=125T{=}125

(b) Deletions, T=125T{=}125

(c) Substitutions, T=500T{=}500

(d) Deletions, T=500T{=}500

Figure 9. Distribution of substitution and deletion intensity over normalized time for \updeltaMDM on GSM8K.

GSM8K accuracy vs. insertion scale

(a) T=250T{=}250

(b) T=500T{=}500

(c) T=1000T{=}1000

Figure 10. GSM8K pass@1 vs. insertion scale at sampling budgets T∈{250,500,1000}T \in \{250,500,1000\}.

Length of generated sequences on OWT

fig:length_distribution compares the quantiles of the generated sequence lengths against the OWT validation set, and Figure 11 shows how the mean length of \updeltaMDM generations changes with the insertion scale λ\lambda.

Figure 11. Mean length of \updeltaMDM generations on OWT vs. insertion scale λ\lambda for different sampling budgets TT.

Remasking: Prior correction approaches in MDMs involve re-masking decoded tokens based on decoding confidence, where tokens are re-masked during inference in proportion to the negative of this probability [26]. More recent works such as [7, 3, 12] add additional heads over pretrained MDMs to estimate token quality in a partially masked sequence, where lower-quality tokens are re-masked for the next unmasking step. Supervision for the correction heads is obtained by randomly replacing correct tokens with other tokens in the vocabulary [3], sampling from the model’s own token distribution [7], or introducing human-injected synthetic errors [4]. Pretrained MDMs are then fine-tuned to optimize the correction loss with MDM loss regularization.

Non-remasking Correction: Contrary to re-masking approaches, [21] proposes alternating unmasking and correction steps. The corrector is conditioned on a more informative sequence obtained by unmasking all positions, and then modifies incorrectly decoded tokens while readjusting the predictive distributions over masked positions. Pretrained MDMs can be fine-tuned to learn this correction, though it requires an additional forward pass during inference. [25] uses a mixed noise schedule with both uniform vocabulary and masked noise, thereby enabling the model to perform token flips. [31] also correct decoded tokens but require architectural changes to the denoising model, thereby necessitating retraining. Seed Diffusion [24] augments MDM training with an edit-based objective that teaches the model token-level edits by recovering the clean sequence from a noisy version that is generated by a controlled corruption process. It drops carry-over unmasking, so the model re-evaluates already-unmasked tokens and can implicitly self-correct.

Variable-Length Masked Diffusion: Fixed-canvas MDMs achieve variable-length control by filling extra positions with padding tokens. Rainbow Padding [5] improves on this by using a cyclic sequence of distinct padding tokens to avoid premature truncation. DAEDAL [9] instead iteratively inserts mask tokens at the end of the initial canvas based on EOS confidence, adapting the canvas length to the prompt before denoising, and further expands low-confidence masked regions with additional mask tokens for dynamic length control during inference. In contrast, insertion-based diffusion approaches such as FlexMDM [6] start from an empty canvas and grow the sequence by iteratively inserting new masks at arbitrary positions while unmasking previously inserted ones. Several flexible-length infilling methods predict the optimal infilling length before denoising , such as using initial-step denoising confidence [11] or a lightweight trained length-probing head [28]. [29] takes an orthogonal approach, allowing token positions to evolve during denoising while using optimal-transport position coupling to preserve relative order, which enables flexible-length text infilling without explicit insertion or deletion operations. Although most prior work on correction focuses on fixed-length MDMs, few approaches address self-correction in variable-length settings like DreamOn [27], which controls length through expansion and deletion operations that adaptively insert and remove masks, achieving superior performance on code-infilling benchmarks. However, it does not perform substitutions, so errors from carry-over unmasking persist.

Randomly Sampled Generations

OpenWebText

GSM8K

Below we show the substitutions from three intermediate steps of a GSM8K generation trajectory with a total budget of T=250T{=}250 steps, followed by the final completion. Mask tokens are denoted by [M], and orange highlighted transitions mark the substitutions that occurred at that time step.

References

  1. [1]Cobbe, Kosaraju, Bavarian, Chen, Jun, Kaiser, Plappert, Tworek, Hilton, Nakano, Hesse, & Schulman. (2021). Training verifiers to solve math word problems, 2021. https://arxiv.org/abs/2110.14168
  2. [2]Gillespie. (2001). Approximate accelerated stochastic simulation of chemically reacting systems. The Journal of chemical physics, 115(4), 1716–1733.
  3. [3]Huang, Wang, Chen, & Qi. (2025). Don't settle too early: Self-reflective remasking for diffusion language models, 2025. https://arxiv.org/abs/2509.23653
  4. [4]Ji, Wang, Ge, Liu, Yang, Shan, & Luo. (2025). From denoising to refining: A corrective framework for vision-language diffusion model, 2025. https://arxiv.org/abs/2510.19871
  5. [5]Kim, Jeon, Kim, Jeung, & No. (2026a). Rainbow padding: Mitigating early termination in instruction-tuned diffusion llms. https://proceedings.iclr.cc/paper_files/paper/2026/file/203221ce5041eddbe0800cef81bfb987-Paper-Conference.pdfproceedings.iclr.cc/paper_files/paper/2026/file/203221ce5041eddbe0800cef81bfb987-Paper-Conference.pdf
  6. [6]Kim, Cheuk-Kit, Domingo-Enrich, Du, Kakade, Ngotiaoco, Chen, & Albergo. (2025a). Any- Order Flexible Length Masked Diffusion , September 2025 a. http://arxiv.org/abs/2509.01025
  7. [7]Kim, Kim, Lee, Pan, Kim, Kakade, & Chen. (2025b). Fine-tuning masked diffusion for provable self-correction, 2025 b. https://arxiv.org/abs/2510.01384
  8. [8]Kim, Kim, Lee, Chen, Du, Kakade, & Chen. (2026b). From interface to inference: Eliciting any-order inference from any-order models, 2026 b. https://arxiv.org/abs/2607.26504
  9. [9]Li, Dong, Zang, Cao, Wang, & Lin. (2026). Beyond fixed: Training-free variable-length denoising for diffusion large language models. https://proceedings.iclr.cc/paper_files/paper/2026/file/940380c12da75e64351cceff4c880557-Paper-Conference.pdfproceedings.iclr.cc/paper_files/paper/2026/file/940380c12da75e64351cceff4c880557-Paper-Conference.pdf
  10. [10]Liu, Bubeck, Eldan, Kulkarni, Li, Nguyen, Ward, & Zhang. (2023). Tinygsm: achieving >80. https://arxiv.org/abs/2312.09241
  11. [11]Liu, Yang, & Su. (2026a). Diffusion lms can approximate optimal infilling lengths implicitly, 2026 a. https://arxiv.org/abs/2602.00476
  12. [12]Liu, Huang, Zhang, Liu, Yin, & Zhao. (2026b). Backplay: Head-only look-back self-correction for diffusion language models, 2026 b. https://arxiv.org/abs/2601.06428
  13. [13]Nie, Zhu, You, Zhang, Ou, Hu, Zhou, Lin, Wen, & LI. (2025). Large language diffusion models. https://proceedings.neurips.cc/paper_files/paper/2025/file/48b383b24230e0e6e649d9c98dae4d8c-Paper-Conference.pdfproceedings.neurips.cc/paper_files/paper/2025/file/48b383b24230e0e6e649d9c98dae4d8c-Paper-Conference.pdf
  14. [14]Patel, Maram, Chintha, Rozonoyer, & McCallum. (2025a). XLM : A Python package for non-autoregressive language models, December 2025 a. http://arxiv.org/abs/2512.17065
  15. [15]Patel, Naseem, Pandey, Sultan, McCallum, & Astudillo. (2025b). Improved sampling from masked diffusion models with position contrastive guidance. https://openreview.net/forum?id=e0WmOrWbtcopenreview.net/forum?id=e0WmOrWbtc
  16. [16]Patel, Sahoo, Amballa, Naseem, Rudner, & McCallum. (2025c). Insertion language models: Sequence generation with arbitrary-position insertions, 2025 c. https://arxiv.org/abs/2505.05755
  17. [17]Patel, Rozonoyer, Das, Naseem, Rudner, & McCallum. (2026a). A continuous time markov chain framework for insertion language models. https://openreview.net/forum?id=nCyV21FmUIopenreview.net/forum?id=nCyV21FmUI
  18. [18]Patel, Rozonoyer, Pandey, Naseem, Astudillo, & McCallum. (2026b). Insertion based sequence generation with learnable order dynamics. https://api.semanticscholar.org/CorpusID:285973138api.semanticscholar.org/CorpusID:285973138
  19. [19]Sahoo, Arriola, Schiff, Gokaslan, Marroquin, Chiu, Rush, & Kuleshov. (2024). Simple and effective masked diffusion language models. https://proceedings.neurips.cc/paper_files/paper/2024/file/eb0b13cc515724ab8015bc978fdde0ad-Paper-Conference.pdfproceedings.neurips.cc/paper_files/paper/2024/file/eb0b13cc515724ab8015bc978fdde0ad-Paper-Conference.pdf
  20. [20]Sahoo, Lemercier, Yang, Deschenaux, Liu, Thickstun, & Jukic. (2026). Scaling beyond masked diffusion language models, 2026. https://arxiv.org/abs/2602.15014
  21. [21]Schiff, Belhasin, Uziel, Wang, Arriola, Turok, Zilberstein, Elad, & Kuleshov. (2026). Learn from Your Mistakes : Self-Correcting Masked Diffusion Models , February 2026. http://arxiv.org/abs/2602.11590
  22. [22]Shi, Han, Wang, Doucet, & Titsias. (2024). Simplified and generalized masked diffusion for discrete data. https://proceedings.neurips.cc/paper_files/paper/2024/file/bad233b9849f019aead5e5cc60cef70f-Paper-Conference.pdfproceedings.neurips.cc/paper_files/paper/2024/file/bad233b9849f019aead5e5cc60cef70f-Paper-Conference.pdf
  23. [23]Song, Sohl-Dickstein, Kingma, Kumar, Ermon, & Poole. (2021). Score-based generative modeling through stochastic differential equations. https://openreview.net/forum?id=PxTIG12RRHSopenreview.net/forum?id=PxTIG12RRHS
  24. [24]Song, Zhang, Luo, Gao, Xia, Luo, Li, Yang, Yu, Qu, Fu, Su, Zhang, Huang, Wang, Yan, Jia, Liu, Ma, … Zhou. (2025). Seed Diffusion : A Large-Scale Diffusion Language Model with High-Speed Inference , August 2025. http://arxiv.org/abs/2508.02193
  25. [25]Von Rütte, Fluri, Ding, Orvieto, Schölkopf, & Hofmann. (2025). Generalized interpolating discrete diffusion. https://proceedings.mlr.press/v267/von-rutte25a.htmlproceedings.mlr.press/v267/von-rutte25a.html
  26. [26]Wang, Schiff, Sahoo, & Kuleshov. (2026). Remasking discrete diffusion models with inference-time scaling, 2026. https://arxiv.org/abs/2503.00307
  27. [27]Wu, Zheng, Xie, Ye, Gao, Gong, Feng, Li, Bi, Zhou, & Kong. (2026). Dreamon: Diffusion language models for code infilling beyond fixed-size canvas, 2026. https://arxiv.org/abs/2602.01326
  28. [28]Xu, Chen, Bei, Chen, Yan, Fu, He, & Tong. (2026). Predict, don't iterate: Efficient adaptive-length infilling for diffusion language models, 2026. https://arxiv.org/abs/2609.02108
  29. [29]Zhang, Sivakumar, Tang, & Thomas. (2025). Flexible-length text infilling for discrete diffusion models. https://aclanthology.org/2025.emnlp-main.1597/aclanthology.org/2025.emnlp-main.1597
  30. [30]Zhang, Wang, Gretton, Ying, van Dijk, Titsias, & Shi. (2026). Variational learning for insertion-based generation, 2026. https://arxiv.org/abs/2606.02133
  31. [31]Zhao, Shi, Chen, Druckmann, Mackey, & Linderman. (2025). Informed correctors for discrete diffusion models, 2025. https://arxiv.org/abs/2407.21243
  32. [32]Zheng, Chen, Mao, Liu, Zhu, & Zhang. (2025). Masked diffusion models are secretly time-agnostic masked models and exploit inaccurate categorical sampling. https://proceedings.iclr.cc/paper_files/paper/2025/file/9e3b203e72c4e058de26d02a92a81844-Paper-Conference.pdfproceedings.iclr.cc/paper_files/paper/2025/file/9e3b203e72c4e058de26d02a92a81844-Paper-Conference.pdf

Paper details

vlnc:W_4pwgfjfq
Version
v1 · latest
Published
Added
License
CC BY 4.0
Usage

views · 14

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

generative AI tools

View statement
Looking for related papers…
Contents