Search-Augmented Masked Diffusion Models for Constrained Generation

Huu Binh Ta, Michael Cardei, Alvaro Velasquez, Ferdinando Fioretto · DOI

Abstract

Discrete diffusion models generate sequences by iteratively denoising samples corrupted by categorical noise, offering an appealing alternative to autoregressive decoding for structured and symbolic generation. However, standard training targets a likelihood-based objective that primarily matches the data distribution and provides no native mechanism for enforcing hard constraints or optimizing non-differentiable properties at inference time. This work addresses this limitation and introduces Search-Augmented Masked Diffusion (SearchDiff), a training-free neurosymbolic inference framework that integrates informed search directly into the reverse denoising process. At each denoising step, the model predictions define a proposal set that is optimized under a user-specified property satisfaction, yielding a modified reverse transition that steers sampling toward probable and feasible solutions. Experiments in biological design and symbolic reasoning illustrate that SearchDiff substantially improves constraint satisfaction and property adherence, while consistently outperforming discrete diffusion and autoregressive baselines.

Introduction

Generative modeling of discrete sequences—such as DNA, small molecules, or symbolic code—has traditionally relied on autoregressive models. While effective, these models generate tokens sequentially, often struggling to maintain global structural coherence. Discrete diffusion models have emerged as a powerful alternative, denoising all tokens in parallel to capture long-range dependencies.

Despite their strengths, standard diffusion models are trained primarily to maximize likelihood, offering no inherent way to enforce hard, non-differentiable constraints (e.g., chemical validity or specific biological properties). Enforcing such constraints typically requires expensive retraining or fine-tuning. SearchDiff addresses this by introducing a training-free, inference-time mechanism to steer generation toward feasible regions of the sequence space.

Methodology: The SearchDiff Framework

SearchDiff modifies the sampling phase of a pre-trained masked diffusion model by embedding a discrete search process directly into the reverse denoising loop. This process consists of three primary stages at each time step $t$:

  1. Predict Clean-State Proposal: The denoiser network predicts a categorical distribution over the fully clean sequence $\hat{x}_0^{(t)}$ based on the current noisy state $x_t$.
  2. Constraint-Aware Search: This stage refines the proposal using two sub-steps. First, Candidate Search Sampling (CSS) draws $M$ candidates from the proposal distribution and selects the one with the lowest constraint violation score $V(x)$. Second, Local Refinement (LS) performs single-token edits on the best CSS candidate to further minimize $V(x)$.
  3. Sample and Commit: The refined candidate $\bar{x}_t$ is used to guide the transition to the next latent state $x_{t-1}$, unmasking tokens based on the improved proposal.
The three-stage SearchDiff inference pipeline: predicting a proposal, refining it via CSS and Local Search, and committing the next latent state.

By interleaving search within the denoising trajectory rather than applying it post-hoc, SearchDiff prevents the model from drifting into unrecoverable, infeasible regions early in the generation process.

Experimental Evaluation

The authors evaluated SearchDiff across several challenging domains requiring strict property adherence:

  • Small Molecules (QM9): Generating molecules optimized for drug-likeness (QED) and synthetic accessibility.
  • Peptides (GRAMPA): Designing antimicrobial peptides constrained by specific biophysical properties like charge and hydrophobicity.
  • Transfer RNA (GtRNAdb): Generating tRNA sequences that must fold into complex, specific secondary structures.
  • Symbolic Reasoning: Solving 9x9 Sudoku puzzles and Boolean Satisfiability (3-SAT) problems.

Key Results

SearchDiff consistently outperformed standard discrete diffusion (MDLM) and autoregressive baselines. In peptide generation, SearchDiff achieved a 100% success rate in satisfying all biophysical constraints. For tRNA generation, it achieved a 27x increase in joint feasibility compared to the best baseline.

Comparison of sample validity across different SearchDiff configurations and baselines, highlighting the additive benefit of CSS and Local Search (LS).

In symbolic reasoning, SearchDiff improved the base diffusion model's accuracy on Boolean SAT from 9.6% to 76.0%, demonstrating its robustness in sparse, combinatorial landscapes.

Discussion and Insights

A critical finding of this work is that Local Search (LS) enables the discovery of out-of-distribution (OOD) solutions. While CSS samples from the model's existing knowledge, LS allows the framework to explore sequences that may have higher property scores than any example in the training set. For instance, SearchDiff generated molecules with QED scores exceeding the maximum value found in the QM9 training data.

While SearchDiff introduces computational overhead due to multiple black-box evaluations per step, it provides a principled, plug-and-play route for making generative models reliable for scientific and symbolic applications. Future work may focus on improving search efficiency or utilizing surrogate models to accelerate the evaluation process.

Summary updated

BibTeX
@misc{ta2026search,
  author = {Huu Binh Ta and Michael Cardei and Alvaro Velasquez and Ferdinando Fioretto},
  title = {{Search-Augmented Masked Diffusion Models for Constrained Generation}},
  year = {2026},
  eprint = {2602.02727},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.02727},
}
Figure