betaFeedback

WorksComputer Science

Hierarchical Masked Diffusion Language Models

Abstract

Masked diffusion language models have emerged as an alternative to autoregressive models, enabling parallel token generation. However, standard masked diffusion language models use a shared noise schedule across positions without explicitly encoding which positions should be resolved first. Many tasks exhibit a natural priority among positions: document titles and section headings can guide the generation of body text, while Sudoku cells determined directly from the initial clues can help resolve more difficult cells. To incorporate this notion of priority (or hierarchy) among token positions, we introduce the Hierarchical Masked Diffusion Language Model (HMDLM), which augments each token position with a hierarchy level available as part of the training data, and requires zero or minimal additional annotations. It factors generation into two passes: the first predicts a hierarchy distribution over masked positions, the second predicts token distributions conditioned on it. Giving each hierarchy level its own noise schedule induces a soft, controllable preference for revealing higher-priority positions earlier while keeping decoding fully parallel. Our formulation is mathematically grounded, and we re-derive the forward and reverse processes and the NELBO for this factorization. Our evaluation shows that for the task of language generation on LM1B, HMDLM reduces perplexity by more than 1.5 points over Anchored Diffusion Language Model (ADLM), a recently proposed strong diffusion baseline; on WikiHow, we see a drop in perplexity of up to 4.4 pts on ADLM and up to 7 pts against MDLM. An LLM judge on WikiHow prefers HMDLM generations (the two variants combined) more than 2×2\times as often as the baseline. On the task of solving Sudoku puzzles requiring multi-step reasoning, it improves solution accuracy by up to 8.6%8.6\% absolute points over existing diffusion baselines.

Introduction

Large language models (LLMs) have revolutionized the AI space, from general-purpose text generation to solving complex problems such as mathematical reasoning and theorem proving. Despite their success, limitations remain. One of the criticisms of modern-day LLMs, which are largely auto-regressive in nature, is that they generate text only in a strictly left-to-right manner. It has been argued that this style of decoding has specific disadvantages, such as not being able to correct past mistakes, and involving large computational costs. As a remedy, recent literature has proposed another class of models, referred to as Diffusion Models [1, 15, 23, 18], which do not subscribe to the left-to-right generation style, but rather generate multiple tokens in parallel. The formulation is based on a forward diffusion process, which translates the text into noise, and on learning the reverse process, can generate the desired text by iteratively denoising from complete noise. This line of work has shown significant promise for the future of language generation, both for increasing computational efficiency and solving complex tasks (e.g., solving Sudoku or generating structured text).

A key open question in masked diffusion language models is how to choose the order in which positions should be denoised. Standard masked diffusion treats token positions symmetrically: with a shared masking schedule and no task-dependent notion of priority. Recent work shows that token ordering and decoding strategies can substantially affect generation quality [12, 5, 9, 4]. Recent approaches address this by identifying important anchor tokens [22, 28], or adding planning-aware training and decoding mechanisms [21, 11]. These methods suggest that not all positions should be treated equally, but none provides a general hierarchy-aware forward and backward diffusion process. Such priority is often available: many problems carry a natural hierarchy over positions. In document generation, titles and section headings or summary often provide high-level semantic structure before the surrounding body text. In Sudoku, more constrained cells are easier to fill first, and their priority belongs to the position, not the digit it will contain.

We introduce HMDLM, a hierarchical extension of masked diffusion language models that associates each token position with a hierarchy variable. During the forward process, both the token and its hierarchy state are diffused toward a masked state. During the reverse process, the model first predicts the hierarchy for masked positions and then predicts token identities conditioned on the predicted hierarchy. This two-stage factorization allows the model to learn which hierarchy level each position belongs to before decoding its token value. Unlike anchor-based methods [22], which tie importance to token identities, HMDLM assigns hierarchy to positions, with a separate noise schedule per level to control how fast each level is unmasked (see § 4.3.2). We also derive the negative evidence lower bound (NELBO) for this process which serves as our training objective 4.

We experimentally validate HMDLM across several benchmark domains. On language modeling benchmarks like LM1B, we train the model from scratch and compare with diffusion baselines (like MDLM [23], SEDD [15], the Anchored Diffusion Language Model (ADLM) [22], and DiffusionBERT [8]) on both perplexity and generation quality. On Wikihow, we fine-tune on pretrained checkpoints and compare with ADLM and MDLM on perplexity and qualitative generation. On Sudoku, we train from scratch, and more reliably produce accurate solutions than the diffusion baselines (like MGDM [29] and MDLM). These results demonstrate that explicitly modeling hierarchy over token positions can improve masked diffusion generation across both natural language and structured domains.

Our work makes the following contributions: (a) We present a novel formulation for incorporating the notion of hierarchy in the discrete diffusion models, referred to as HMDLM (b) We re-formulate the standard diffusion formulation to have a two stage training and inference process, where the first stage predicts distribution over hierarchy levels, and second one predicts token distribution given the hierarchy prediction. (c) We re-derive the ELBO to incorporate the notion of hierarchy in the forward and backward diffusion process. (d) We present experiments showing gains over masked diffusion baselines in perplexity and generation quality on LM1B and WikiHow, and report accuracy on Sudoku. We also plan to release the code for HMDLM on paper acceptance.

Related Work

Masked diffusion language models: Diffusion models have recently been adapted to language generation as an alternative to left-to-right autoregressive modeling. Early approaches explored diffusion in continuous word-vector spaces, as in Diffusion-LM [14], or directly over discrete tokens, as in D3PMs [1] with structured transition matrices and absorbing [MASK] states. More recent masked diffusion language models formulate generation as iterative denoising from partially masked sequences: the forward process gradually replaces tokens with [MASK], and the reverse model reconstructs the sequence from bidirectional context. SEDD [15], reparameterized discrete diffusion [30], DiffusionBERT [8], MD4 [24] and MDLM [23] improve the objectives and sampling procedures for this setting, while large-scale systems such as MDM [16], LLaDA [17] and LLaDA2.0 [2] show that masked diffusion can support instruction-following LLMs. However, these models typically employ a uniform masking schedule, ignoring the inherent semantic or structural hierarchy of the task.

Generation order and decoding strategies: Masked diffusion is attractive because generation need not proceed left-to-right; tokens can be revealed in arbitrary or partially parallel orders. This flexibility also makes the choice of denoising order important. Prior work shows that adaptive or learned ordering can significantly improve masked diffusion, through inference-time token ordering [12], planner-aware training [21], planned generation where the model first constructs a high-level plan and then denoises the planned spans in parallel [11], variational order learning [4], or unified learnable-order formulations [9]. Other methods [26, 10] modify sampling trajectories to address irreversibility or decoding bias. Our work is complementary: rather than learning a free-form position policy or adding an external planner, HMDLM encodes a task-dependent hierarchy in the diffusion state itself and uses per-level schedules to induce a controllable soft generation order.

Anchoring, planning, and structured priors: Several recent works also argue that diffusion language models benefit from identifying important tokens or high-level structure before completing the full sequence. Anchored Diffusion Language Models [22] observe that masking important words early can remove useful context, and use a two-stage model that predicts anchor-token distributions before predicting missing tokens. Planned Diffusion [11] first constructs an explicit plan and then generates spans in parallel. In code generation, AnCoder [28] uses syntax-tree priors to prioritize keywords and identifiers, and code-focused diffusion models such as DiffuCoder and Dream-Coder further show the value of domain-specific structure [7, 27]. These works share our motivation that not all sequence positions should be treated equally. However, HMDLM differs by attaching hierarchy to positions rather than only token identities, supporting multiple task-defined hierarchy levels, and using these levels to control both the forward corruption process and the reverse denoising dynamics through level-specific schedules.

Background

Notations

Let xx denote a sequence of discrete tokens each token xix^{i} is represented as one-hot column vector, and V={xi∈{0,1}D:∑j=1Dxi[j]=1}\mathcal{V} = \{x^{i} \in\{0,1\}^{D} : \sum_{j=1}^{D} x^{i}[j] = 1\} at position ii as the set of all such vectors. Define Cat⁡(⋅;π)\operatorname{Cat}(\cdot;\boldsymbol{\pi}) as the categorical distribution over V\mathcal{V} classes, where π∈RD\boldsymbol{\pi} \in\mathbb{R}^{D} and ∑dπ[d]=1\sum_{d}\pi[d] = 1. Also we assume a special [MASK][\mathit{MASK}] token, m∈Vm \in\mathcal{V} and treat it as the DthD^{\mathrm{th}} category, i.e., m[D]=1m[D] = 1. Let xtx_t denote the state of the diffusion process at time step tt. The following description follows the treatment provided in [23].

Discrete Diffusion Models

Forward process. Discrete diffusion process is defined using a forward process that gradually corrupts data over TT time steps, and replaces each token with a special MASK token. Let t∈{0,1,…,T}t \in\{0,1,\ldots,T\}, with t=0t=0 corresponding to clean data and t=Tt=T to fully masked data, and xti∈Vx_t^{i} \in\mathcal{V} denote progressively noisier latent variables where the timestep tt ranges from 0 (zero noise) to TT (maximum noise). The forward noising process qq at time tt and position ii is defined as:

q(xti∣x0i)=Cat⁡(xti;αtx0i+(1−αt)m),(1)q(x_t^{i} \mid x_0^{i}) = \operatorname{Cat}(x_t^{i};\alpha_t x_0^{i} + (1-\alpha_t)m), \tag*{(1)}

where x0ix_0^{i} is the clean state, αt\alpha_t is the masking schedule where αt∈[0,1]\alpha_t \in[0,1] is a strictly decreasing function in tt, with α0=1\alpha_0 = 1 and αT=0\alpha_T = 0 controlling the proportion of unmasked tokens at time tt. The corresponding posterior transition with λt=αt−1−αt1−αt\lambda_t = \frac{\alpha_{t-1}-\alpha_t}{1-\alpha_t} is:

q(xt−1i∣xti,x0i)={Cat⁡(xt−1i;xti),xti≠m,Cat⁡(xt−1i;(1−λt)m+λtx0i),xti=m.(2)q(x_{t-1}^{i} \mid x_t^{i},x_0^{i}) = \begin{cases} \operatorname{Cat}(x_{t-1}^{i};x_t^{i}), & x_t^{i} \ne m,\\ \operatorname{Cat}(x_{t-1}^{i};(1-\lambda_t)m+\lambda_t x_0^{i}), & x_t^{i}=m. \end{cases} \tag*{(2)}

Reverse process. The reverse process iteratively denoises the data from timestep tt to t−1t-1 until the sequence becomes fully unmasked. Diffusion model aims to approximate the reverse process by learning a backward model pθ(xt−1i∣xti)p_{\theta}(x_{t-1}^{i}\mid x_t^{i}). Since the true posterior depends on the unknown clean token x0ix_0^{i}, it is approximated with a neural network xθi(xt,t)∈ΔVx_{\theta}^{i}(x_t,t) \in\Delta^{\mathcal{V}}, which predicts the clean token distribution from the noisy input xtix_t^{i} at time tt. During the reverse diffusion process, unmasked tokens stay fixed, and clean inputs are never masked:

pθ(xt−1i∣xt)={Cat⁡(xt−1i;xti),xti≠m,Cat⁡(xt−1i;(1−λt)m+λtxθi(xt,t)),xti=m.(3)p_{\theta}(x_{t-1}^{i} \mid x_t) = \begin{cases} \operatorname{Cat}(x_{t-1}^{i};x_t^{i}), & x_t^{i} \ne m,\\ \operatorname{Cat}(x_{t-1}^{i};(1-\lambda_t)m+\lambda_t x_{\theta}^{i}(x_t,t)), & x_t^{i}=m. \end{cases} \tag*{(3)}

NELBO. The denoising model xθ(xt,t)x_\theta(x_t,t) is trained using the following Negative ELBO:

LNELBO(x;θ)=Eq,t[−log⁡pθ(x0∣x1)+T(αt−αt−11−αtlog⁡⟨xθ(xt,t),x0⟩)](4)\mathcal{L}_{\mathrm{NELBO}}(x;\theta)=\mathbb{E}_{q,t}\left[-\log p_\theta(x_0\mid x_1)+T\left(\frac{\alpha_t-\alpha_{t-1}}{1-\alpha_t}\log\langle x_\theta(x_t,t),x_0\rangle\right)\right] \tag*{(4)}

Hierarchical Masked Diffusion Language Model

In this section we introduce the Hierarchical Masked Diffusion Language Model (HMDLM), which extends discrete diffusion models by incorporating a notion of hierarchy into both the forward and backward processes. Our framework augments each token position with a hierarchy level. Let h0ih_0^i denote the gold hierarchy at position ii, represented as a one-hot vector over KK levels, i.e., h0i∈{0,1}Kh_0^i \in\{0,1\}^K. We introduce a distinct hierarchy mask state hmh_m, giving K+1K+1 possible hierarchy states. Positions to be unmasked at time step tt are governed by the level dependent masking schedule αk(t)\alpha_k(t) defined for time step t∈{0,…,T}t \in\{0,\ldots,T\} and level k∈{0,…,K−1}k \in\{0,\ldots,K-1\} which is a decreasing function. If a position ii at time step tt is sampled or is already unmasked, we then set bti=0b_t^i=0 and bti=1b_t^i=1 otherwise.

sti=(xti,hti)={(x0i,h0i)if bti=0 (revealed),(m,hm)if bti=1 (masked).(5)s_t^i=(x_t^i,h_t^i)= \begin{cases} (x_0^i,h_0^i) & \text{if } b_t^i=0\ \text{(revealed)},\\ (m,h_m) & \text{if } b_t^i=1\ \text{(masked)}. \end{cases} \tag*{(5)}

Since btib_t^i is shared, a token and its hierarchy level are always masked or revealed together, ruling out decoupled states such as a masked token with a revealed level.

Forward and Reverse Process

Forward Process The forward process is a fixed Markov chain, that progressively masks tokens from the initial state s0s_0 to a noisy state sts_t at each time step tt over TT time steps, according to the hierarchy conditioned noise schedule αk(t)\alpha_k(t). Tokens at lower hierarchy levels are masked more aggressively at early time-steps, than tokens at higher hierarchy levels. The forward marginal at a single token position ii with hierarchy kk and joint state sti=(xti,hti)s_t^i=(x_t^i,h_t^i) is given by:

q(sti∣s0i)=Cat⁡(sti;αh0i(t)s0i+(1−αh0i(t))sm)(6)q(s_t^i\mid s_0^i)=\operatorname{Cat}\left(s_t^i;\alpha_{h_0^i}(t)s_0^i+\left(1-\alpha_{h_0^i}(t)\right)s_m\right) \tag*{(6)}

At t=Tt=T, all tokens are fully masked regardless of the hierarchy level, i.e. αk(T)=0\alpha_k(T)=0. Let

λk(t)=αk(t−1)−αk(t)1−αk(t)\lambda_k(t)=\frac{\alpha_k(t-1)-\alpha_k(t)}{1-\alpha_k(t)}

denote the probability that a masked level-kk position is revealed at step tt, with λk(t)=0\lambda_k(t)=0 when αk(t)=1\alpha_k(t)=1. The true joint posterior is:

References

  1. [1]Jacob Austin, Daniel D Johnson, Jonathan Ho, Daniel Tarlow, and Rianne Van Den Berg. Structured denoising diffusion models in discrete state-spaces. Advances in neural information processing systems, 34:17981–17993, 2021.arxiv.org/abs/2107.03006
  2. [2]Tiwei Bie, Maosong Cao, Kun Chen, Lun Du, Mingliang Gong, Zhuochen Gong, Yanmei Gu, Jiaqi Hu, Zenan Huang, Zhenzhong Lan, et al. Llada2. 0: Scaling up diffusion language models to 100b. arXiv preprint arXiv:2512.15745, 2025.arxiv.org/abs/2512.15745
  3. [3]Ciprian Chelba, Tomas Mikolov, Mike Schuster, Qi Ge, Thorsten Brants, Philipp Koehn, and Tony Robinson. One billion word benchmark for measuring progress in statistical language modeling. arXiv preprint arXiv:1312.3005, 2013.arxiv.org/abs/1312.3005
  4. [4]David Fox, Sam Bowyer, Song Liu, Laurence Aitchison, Raul Santos-Rodriguez, and Mengyue Yang. Learning generation orders for masked discrete diffusion models via variational inference. In 2nd Workshop on Deep Generative Model in Machine Learning: Theory, Principle and Efficacy, ICLR 2026, 2026.
  5. [5]Prateek Garg, Bhavya Kohli, and Sunita Sarawagi. Masked diffusion models are secretly learned-order autoregressive models. In EurIPS 2025 Workshop on Principles of Generative Modeling (PriGM), 2025.arxiv.org/abs/2511.19152
  6. [6]Aaron Gokaslan and Vanya Cohen. Openwebtext corpus. http://Skylion007.github.io/OpenWebTextCorpus, 2019.
  7. [7]Shansan Gong, Ruixiang Zhang, Huangjie Zheng, Jiatao Gu, Navdeep Jaitly, Lingpeng Kong, and Yizhe Zhang. Diffucoder: Understanding and improving masked diffusion models for code generation. arXiv preprint arXiv:2506.20639, 2025.arxiv.org/abs/2506.20639
  8. [8]Zhengfu He, Tianxiang Sun, Qiong Tang, Kuanning Wang, Xuan-Jing Huang, and Xipeng Qiu. Diffusionbert: Improving generative masked language models with diffusion models. In Proceedings of the 61st annual meeting of the association for computational linguistics (volume 1: Long papers), pp. 4521–4534, 2023.arxiv.org/abs/2211.15029
  9. [9]Chunsan Hong, Sanghyun Lee, and Jong Chul Ye. Unifying masked diffusion models with various generation orders and beyond. arXiv preprint arXiv:2602.02112, 2026.arxiv.org/abs/2602.02112
  10. [10]Pengcheng Huang, Shuhao Liu, Zhenghao Liu, Yukun Yan, Shuo Wang, Zulong Chen, and Tong Xiao. Pc-sampler: Position-aware calibration of decoding bias in masked diffusion models. arXiv preprint arXiv:2508.13021, 2025.
  11. [11]Daniel Israel, Tian Jin, Ellie Cheng, Guy Van den Broeck, Aditya Grover, Suvinay Subramanian, and Michael Carbin. Planned diffusion. arXiv preprint arXiv:2510.18087, 2025.arxiv.org/abs/2510.18087
  12. [12]Jaeyeon Kim, Kulin Shah, Vasilis Kontonis, Sham M Kakade, and Sitan Chen. Train for the worst, plan for the best: Understanding token ordering in masked diffusions. In International Conference on Machine Learning, pp. 30749–30768. PMLR, 2025.arxiv.org/abs/2502.06768
  13. [13]Mahnaz Koupaee and William Yang Wang. Wikihow: A large scale text summarization dataset, 2018. URL https://arxiv.org/abs/1810.09305.
  14. [14]Xiang Li, John Thickstun, Ishaan Gulrajani, Percy S Liang, and Tatsunori B Hashimoto. Diffusion-lm improves controllable text generation. Advances in neural information processing systems, 35: 4328–4343, 2022.arxiv.org/abs/2205.14217
  15. [15]Aaron Lou, Chenlin Meng, and Stefano Ermon. Discrete diffusion modeling by estimating the ratios of the data distribution. In Proceedings of the 41st International Conference on Machine Learning, pp. 32819–32848, 2024.arxiv.org/abs/2310.16834
  16. [16]Shen Nie, Fengqi Zhu, Chao Du, Tianyu Pang, Qian Liu, Guangtao Zeng, Min Lin, and Chongxuan Li. Scaling up masked diffusion models on text. In Y. Yue, A. Garg, N. Peng, F. Sha, and R. Yu (eds.), International Conference on Learning Representations, volume 2025, pp. 82974–82997, 2025a. URL https://proceedings.iclr.cc/paper_files/paper/2025/file/ce1c1ff5d94079dea348a2317a889281-Paper-Conference.pdf.arxiv.org/abs/2410.18514
  17. [17]Shen Nie, Fengqi Zhu, Zebin You, Xiaolu Zhang, Jingyang Ou, Jun Hu, Jun Zhou, Yankai Lin, Ji-Rong Wen, and Chongxuan Li. Large language diffusion models. arXiv preprint arXiv:2502.09992, 2025b.arxiv.org/abs/2502.09992
  18. [18]Shen Nie, Fengqi Zhu, Zebin You, Xiaolu Zhang, Jingyang Ou, Jun Hu, Jun Zhou, Yankai Lin, Ji-Rong Wen, and Chongxuan Li. Large language diffusion models, 2025c. URL https://arxiv.org/abs/2502.09992.
  19. [19]Rasmus Palm, Ulrich Paquet, and Ole Winther. Recurrent relational networks. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 31, pp. 3372–3382. Curran Associates, Inc., 2018. URL http://nips.cc.arxiv.org/abs/1711.08028
  20. [20]William Peebles and Saining Xie. Scalable diffusion models with transformers, 2023. URL https://arxiv.org/abs/2212.09748.
  21. [21]Fred Zhangzhi Peng, Zachary Bezemek, Jarrid Rector-Brooks, Shuibai Zhang, Anru R Zhang, Michael Bronstein, Alexander Tong, and Avishek Joey Bose. Planner aware path learning in diffusion language models training. arXiv preprint arXiv:2509.23405, 2025.arxiv.org/abs/2509.23405
  22. [22]Litu Rout, Constantine Caramanis, and Sanjay Shakkottai. Anchored diffusion language model, 2025. URL https://arxiv.org/abs/2505.18456.
  23. [23]Subham S Sahoo, Marianne Arriola, Yair Schiff, Aaron Gokaslan, Edgar Marroquin, Justin T Chiu, Alexander Rush, and Volodymyr Kuleshov. Simple and effective masked diffusion language models. Advances in Neural Information Processing Systems, 37:130136–130184, 2024.arxiv.org/abs/2406.07524
  24. [24]Jiaxin Shi, Kehang Han, Zhe Wang, Arnaud Doucet, and Michalis Titsias. Simplified and generalized masked diffusion for discrete data. Advances in neural information processing systems, 37:103131–103167, 2024.arxiv.org/abs/2406.04329
  25. [25]Jianlin Su, Murtadha Ahmed, Yu Lu, Shengfeng Pan, Wen Bo, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024.arxiv.org/abs/2104.09864
  26. [26]Guanghan Wang, Yair Schiff, Subham Sahoo, and Volodymyr Kuleshov. Remasking discrete diffusion models with inference-time scaling. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025. URL https://openreview.net/forum?id=I rYqAOyOp.arxiv.org/abs/2503.00307
  27. [27]Zhihui Xie, Jiacheng Ye, Lin Zheng, Jiahui Gao, Jingwei Dong, Zirui Wu, Xueliang Zhao, Shansan Gong, Xin Jiang, Zhenguo Li, et al. Dream-coder 7b: An open diffusion language model for code. arXiv preprint arXiv:2509.01142, 2025.arxiv.org/abs/2509.01142
  28. [28]Anton Xue, Litu Rout, Constantine Caramanis, and Sanjay Shakkottai. Ancoder: Anchored code generation via discrete diffusion models. arXiv preprint arXiv:2602.17688, 2026.arxiv.org/abs/2602.17688
  29. [29]Jiacheng Ye, Jiahui Gao, Shansan Gong, Lin Zheng, Xin Jiang, Zhenguo Li, and Lingpeng Kong. Beyond autoregression: Discrete diffusion for complex reasoning and planning. In International Conference on Learning Representations (ICLR), 2025.arxiv.org/abs/2410.14157
  30. [30]Lin Zheng, Jianbo Yuan, Lei Yu, and Lingpeng Kong. A reparameterized discrete diffusion model for text generation. arXiv preprint arXiv:2302.05737, 2023.arxiv.org/abs/2302.05737

Paper details

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

views · 0

downloads · 0

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

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents