TL;DR
Generative models are great at mimicking what they’ve seen, but notoriously bad at following strict, brittle rules—like designing a chemically valid drug or solving a Boolean logic puzzle. SearchDiff fixes this without any model retraining by embedding a classic discrete search directly inside the iterative "unmasking" steps of a discrete diffusion model. The result is a plug-and-play inference framework that marries neural intuition with hard symbolic evaluators, drastically improving rule-following and discovering novel solutions outside the training distribution.
What Problem Does This Paper Address?
If you ask a standard autoregressive language model (like GPT) to generate a molecule or solve a Sudoku board left-to-right, early token choices can trap it in a dead end before it ever sees the whole picture. Masked discrete diffusion models offer an appealing alternative: they start with a sequence of [MASK] tokens and reveal the whole structure iteratively in parallel, giving the model a global view of the sequence at every step.
However, diffusion models are trained simply to match the statistical likelihood of their training data. They have no built-in way to enforce hard rules (like "zero duplicate numbers in a Sudoku row") or optimize non-differentiable, black-box simulators (like chemical synthesizability). Existing workarounds require retraining the model for every new rule or relying on smooth, differentiable approximations that introduce bias and degrade quality. We need a way to enforce strict, arbitrary rules at inference time without touching the base model's weights.
Methods
SearchDiff hijacks the standard reverse-diffusion loop. Normally, at each step $t$, a masked diffusion model looks at a partially masked sequence, guesses a probability distribution over clean tokens, and randomly unmasks a few positions. SearchDiff inserts a neurosymbolic search step right into the middle of that transition:
- Clean-State Proposal (Standard): The pretrained denoiser network predicts token probabilities for the entire sequence.
- Constraint-Aware Search (Novel): Instead of immediately sampling from those raw probabilities, SearchDiff treats them as an informed prior for a two-part discrete search evaluated by a black-box constraint checker:
- Candidate Search Sampling (CSS): Draw $M$ full, clean candidate sequences from the denoiser’s proposal distribution and pick the one with the lowest constraint violation.
- Local Search Refinement (LS): Take that winning candidate and test single-token edits (a Hamming-1 neighborhood), greedily stepping toward the neighbor that best reduces rule violations.
- Modified Reverse Kernel (Novel): Advance to step $t-1$. Already unmasked tokens are updated deterministically, while masked positions stochastically decide whether to stay
[MASK]or commit to the token found by the refined search candidate.
Because the search only queries constraint violations, it requires zero gradients and works with any off-the-shelf simulator or solver.
Datasets
The authors evaluate SearchDiff across five existing scientific and symbolic benchmarks (no new datasets are introduced, following prior setups):
- Small Molecules: QM9 dataset (SMILES strings), evaluated with RDKit for validity, drug-likeness (QED), and Synthetic Accessibility (SA).
- Peptides: Antimicrobial/host-defense amino-acid sequences evaluated with Biopython for length, net charge, and hydrophobicity.
- Transfer RNA (tRNA): Sequences evaluated with ViennaRNA for tightly coupled secondary-structure folding motifs.
- Symbolic Logic: $9\times 9$ Sudoku boards and random 7-variable, 45-clause 3-SAT Boolean formulas.
Key Insights and Ideas
- Local search unlocks Out-of-Distribution (OOD) discovery: Sampling-only methods are prisoner to what the base model already thinks is likely. Because Local Search tests single-token neighbor edits directly against the evaluator, it actively walks into feasible, high-reward regions the model never saw during training.
- Trajectory-level steering beats post-hoc repair: What happens if you just run normal diffusion and apply local search at the very last step? On 3-SAT, accuracy crawls from 9.6% to 11.4%. Interleaving search throughout the denoising trajectory jumps accuracy to 76.0%, proving that early, iterative nudges prevent the model from drifting into unrecoverable regions.
- Neural priors and search need each other: Running greedy local search from a random start gets 0% on Sudoku and 45.8% on SAT. The diffusion model provides the global intuition; the search provides the exactness.
Key Results
- Molecules: Setting a constraint of $\text{QED} \ge 0.7$ yields 833.4 valid, novel, unique molecules (out of 1024), more than doubling vanilla MDLM (397.8) while boosting mean QED from 0.48 to 0.72. Under strict synthesizability ($\text{SA} \le 4$), SearchDiff produces 470.2 qualifying molecules (~4$\times$ vanilla MDLM's 119.2). It also discovers an average of 332.4 molecules with higher QED than the best molecule in the entire training set (vanilla MDLM and classifier-based guidance find 0.0).
- Peptides & tRNA: Achieves a 0% violation rate on peptides (1024/1024 valid, unique, novel sequences satisfying all biophysical rules). On the much harder, long-range tRNA folding task, it achieves a 27$\times$ increase in joint constraint satisfaction over the best baseline (719.0 vs. 25.8).
- Symbolic Reasoning: Using just a tiny 6M-parameter diffusion backbone, SearchDiff hits 96.5% on Sudoku (beating a 303M GPT-2 model at 23.21%) and boosts 3-SAT accuracy nearly 8$\times$ over vanilla diffusion (from 9.6% to 76.0%).
Limitations and Future Work
While the authors do not include a dedicated limitations section in the main text, one practical trade-off is noted in the molecular experiments: purely greedy property maximization in SearchDiff can cause the search to collapse onto repeated samples, reducing uniqueness (which the authors mitigate by switching from pure maximization to a threshold constraint like $\text{QED} \ge 0.7$). Additionally, local search is restricted to single-token (Hamming-1) edits per step to keep computational complexity manageable. Looking forward, the authors suggest that trajectory-level, inference-time optimization offers a broader, principled route for making discrete generative models reliable across scientific discovery and symbolic reasoning workflows.
Summary updated