Dynamic Infilling Anchors for Format-Constrained Generation in Diffusion Large Language Models

Boyan Han, Yiwei Wang, Yi Song, Yujun Cai, Chi ZhangarXiv 2026 · arXiv

TL;DR

Diffusion large language models (dLLMs) excel at parallel text generation but struggle to maintain strict formatting constraints without sacrificing output quality. This paper introduces Dynamic Infilling Anchors (DIA), a training-free method that allows dLLMs to dynamically predict and adjust the generation space between structural tags (like JSON keys or reasoning tokens) before filling in the content. DIA significantly boosts both format compliance and reasoning accuracy across complex math and structured data benchmarks.

What Problem Does This Paper Address?

Enforcing structured outputs—such as valid JSON or explicit <think>...</think> reasoning chains—is a notorious headache in language modeling. While traditional autoregressive models rely on complex constrained decoding or heavy fine-tuning, diffusion large language models (dLLMs) offer a unique alternative. Because dLLMs use bidirectional attention and generate tokens in parallel by iteratively denoising a fully masked sequence, you can theoretically force a format simply by pre-filling structural "anchors" (tags) directly into the initial mask sequence.

However, the authors point out a major flaw in this naive "Fixed-position Infilling" approach: rigidity. If you fix the distance between <think> and </think> tags in advance, the generation space becomes a straightjacket. If the span is too short, the model's reasoning gets truncated prematurely. If it's too long, the model hallucinates redundant or repetitive tokens just to fill the empty space.

Methods

To break free from this spatial rigidity, the authors propose Dynamic Infilling Anchors (DIA), a two-stage, training-free inference strategy:

  1. Stage 1: Generation Length Adjustment: The model initializes a relatively short, fully masked sequence divided into blocks (e.g., a reasoning block and an answering block). It inserts the opening anchor (e.g., <think>) and runs a single-step prediction. If the model fails to predict the corresponding closing anchor (e.g., </think>) with a confidence score above a threshold $c$, it assumes the current generation space is insufficient. The block is then expanded by appending $\Delta$ masked tokens, and the single-step prediction is repeated. This "predict-decide" loop continues until the closing anchor is confidently located or a maximum length $M$ is reached.
  2. Stage 2: Iterative Denoising with Infilling: With the anchors now dynamically fixed at optimal positions, the model performs standard iterative diffusion denoising to fill in the actual content between the boundaries.
Figure 1: Dynamic Infilling Anchors (DIA). (a) Fixed-position infilling baseline. (b) Overview about our methods: DIA. (c) Details of expansion and anchor infilling steps with truncation and remasking.

Datasets

The authors evaluated DIA on three prominent benchmarks:

  • GSM8K: Grade-school math word problems evaluated in a zero-shot setting to test multi-step arithmetic reasoning.
  • MATH: A highly challenging dataset containing competition-level math problems across algebra, calculus, and more.
  • WikiBio: A dataset of Wikipedia biographies. The authors sampled 10,000 instances to construct a structured data-to-text task where the model must output predefined fields in strict JSON format.

Key Insights and Ideas

  • dLLMs Have Spatial Awareness: A key "aha moment" of this paper is that a dLLM's single-step confidence profile across a masked sequence implicitly reflects its prior knowledge of how long a response should be. DIA leverages this property to let the model "scout ahead" and plan its boundaries before generating text.
  • Decoupling Length Planning from Content Generation: Autoregressive models must decide when to stop token-by-token. DIA demonstrates that dLLMs can completely decouple length planning from content generation, treating formatting as an explicit layout optimization problem.
  • The Fixed-Span Paradox: Forcing static structural constraints actually degrades a model's reasoning capacity. Giving the model room to dynamically stretch its "thinking space" directly correlates with its ability to find correct answers.

Key Results

DIA achieved substantial improvements in both structural fidelity and task accuracy over standard baselines (Dream-7B-Base/Instruct) and fixed infilling methods:

  • Reasoning Benchmarks: On GSM8K, DIA raised format correctness from 58.83% (Fixed Infilling) to 72.63%, while simultaneously skyrocketing answer accuracy from 14.86% to 46.78%. On the brutal MATH benchmark, it boosted format compliance from 29.10% to 76.82% while maintaining competitive accuracy.
  • JSON Generation: On the WikiBio task, fixed infilling suffered a catastrophic failure rate (0.01% valid JSON). DIA achieved an impressive 79.84% valid JSON rate with an incredibly low hallucination score of just 0.15%.
  • The Latency Surprise: While the dynamic expansion loop adds overhead on simpler tasks (like GSM8K), DIA actually achieved lower average latency than all baselines on the complex MATH dataset (30.62s vs 31.71s for Base). This efficiency is due to Stage 1's upfront length planning, which prevents the model from wasting parallel compute steps on redundant tokens.
Anchor retention ratios on GSM8K and MATH

Limitations and Future Work

Despite its strong performance, DIA has a few clear limitations:

  • Manual Anchor Specification: The method relies on human-defined anchors with fixed semantic roles. This restricts its use in fluid, open-ended scenarios like open-domain dialogue where structural boundaries shift dynamically.
  • Inference Overhead on Simple Tasks: For shorter tasks where length planning isn't strictly necessary, the iterative expansion steps introduce modest latency overhead.

For future directions, the authors suggest exploring automated anchor design and hierarchical constraints to make the framework more flexible and universally applicable.

Summary updated

Abstract

Diffusion large language models (dLLMs) offer bidirectional attention and parallel generation, enabling them to exploit global context and naturally support format-constrained tasks like parseable JSON or reasoning templates. While straightforward fixed anchors can enforce such constraints, they often impose rigid spans, leading to truncated reasoning or redundant content. To overcome this, we propose Dynamic Infilling Anchors (DIA), a training-free method that dynamically estimates end-anchor positions to adjust generation length before iterative infilling. This flexible mechanism ensures structural correctness and semantic coherence, avoiding the inefficiencies of fixed-span methods. Experiments on reasoning benchmarks demonstrate that DIA substantially improves format compliance and answer accuracy, achieving significant zero-shot gains on GSM8K and MATH. These results establish DIA as a robust pathway toward reliable, structure-aware generation.
BibTeX
@misc{han2026dynamic,
  author = {Boyan Han and Yiwei Wang and Yi Song and Yujun Cai and Chi Zhang},
  title = {{Dynamic Infilling Anchors for Format-Constrained Generation in Diffusion Large Language Models}},
  year = {2026},
  eprint = {2606.04535},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.04535},
}

Loading related content...

Figure