TL;DR
DyStruct is a training-free, Bayesian structured decoding framework that enables diffusion language models (DLMs) to generate flexible-length text without costly retraining. By dynamically inferring window sizes, partitioning text into blocks using a Chinese Restaurant Process, and scheduling the decoding order based on context stability, DyStruct significantly improves generation quality and efficiency over existing fixed- and variable-length baselines.
What Problem Does This Paper Address?
While autoregressive large language models (LLMs) generate text token-by-token, Diffusion Language Models (DLMs) offer a highly efficient alternative by iteratively refining multiple token positions in parallel. However, standard DLMs suffer from a major limitation: they typically require a fixed generation length to be specified before decoding begins. This lack of flexibility leads to either truncated responses or redundant padding.
Recent attempts to introduce variable-length decoding to DLMs either require expensive model retraining or rely on local, heuristic confidence thresholds. These local heuristics fail to capture the evolving semantic structure of a sequence, frequently resulting in fragmented text and poor logical coherence. DyStruct addresses this gap by treating flexible-length generation as a dynamic, training-free structural inference problem at decoding time.
Methods
DyStruct introduces a unified Bayesian framework that operates entirely at inference time on frozen DLMs. The core algorithm breaks down decoding into an iterative cycle of four main steps:
- Adaptive Window Expansion: Instead of appending a fixed number of masks, the decoder determines the next window size ($L_t$) dynamically. It samples from a Poisson distribution scaled by the structural instability (uncertainty) of the previously decoded tokens. Stable context allows for larger window expansions, while high instability restricts growth to prevent error propagation.
- CRP-Style Partitioning: To organize newly introduced tokens, DyStruct uses a Chinese Restaurant Process (CRP) prior combined with local token instability metrics. This allows the model to adaptively cluster tokens into contiguous blocks without predefining the number of blocks or their boundaries.
- Context-Aware Scheduling: Rather than decoding text strictly from left to right, DyStruct uses a Gibbs distribution to prioritize the decoding order of the blocks. Blocks that are well-anchored by existing context and exhibit low instability are resolved first, providing stable conditioning for more complex, high-instability regions.
- Local Boundary Repair (Edge-Welding): Because blocks are resolved independently, boundary tokens can suffer from disjoint contexts. DyStruct applies an "edge-welding" step that performs localized remasking and refinement at block interfaces to ensure structural consistency and smooth transitions.
The overall workflow of the framework is illustrated below:
Datasets
The authors evaluated DyStruct across three distinct domains using five standard benchmarks:
- Mathematical Reasoning: GSM8K (5-shot) and MATH (4-shot), evaluated using strict-match accuracy.
- Code Generation: MBPP (3-shot) and HumanEval (0-shot), evaluated using greedy pass@1 accuracy.
- Multi-Step Logical Reasoning: Big-Bench Hard (BBH) (3-shot), evaluated using exact match accuracy.
Key Insights and Ideas
- Mitigating Distributional Drift: Parallel decoding over massive unanchored mask windows causes severe distributional drift because tokens lack conditional anchors. Breaking the generation into dynamically sized, structurally inferred blocks acts as a powerful regularizer.
- The Power of Non-Monotonic Decoding: Complex reasoning and coding tasks inherently require bidirectional conditioning. Forcing a strict left-to-right decoding order degrades performance. Prioritizing stable "anchor" blocks first allows the model to resolve intermediate logical transitions far more accurately.
- Compute Follows Complexity: By dynamically adjusting refinement steps based on block instability, DyStruct naturally allocates more computational budget to difficult logical transitions while terminating early on simple, repetitive syntactic templates.
Key Results
DyStruct consistently outperformed both fixed-length baselines and state-of-the-art variable-length decoding methods like DAEDAL across all benchmarks, using both LLaDA-8B and Dream-7B backbones.
- Accuracy Gains: On the LLaDA-8B backbone, DyStruct boosted BBH exact match accuracy from 44.9% to 49.3%. On the Dream-7B backbone, it achieved a massive 6.8-point absolute improvement on HumanEval (rising to 47.0%).
- Efficiency Improvements: On tasks with highly structured, predictable syntax like GSM8K, DyStruct achieved early termination in low-instability regions. This significantly reduced the seconds-per-iteration (s/it) footprint compared to fixed-length models that are forced to denoise the entire window for the maximum number of steps.
Ablation studies confirmed that removing either the context-aware block scheduling or the edge-welding boundary repair led to noticeable drops in performance, underscoring the necessity of joint structural inference.
Limitations and Future Work
The primary limitation of DyStruct is that it operates purely at inference time as a post-hoc decoding strategy. While this makes it universally applicable to frozen DLMs without retraining, the authors note that integrating structural inference directly into the training phase of diffusion language models could yield even stronger structural awareness and performance gains.
Summary updated