Diffusion On Syntax Trees For Program Synthesis

Shreyas Kapur, Erik Jenner, Stuart Russell
2/12/2026

No official code found. Best implementation: revalo/tree-diffusion (485 stars, MIT, last commit 2024-06-27).

Abstract

Large language models generate code one token at a time. Their autoregressive generation process lacks the feedback of observing the program's output. Training LLMs to suggest edits directly can be challenging due to the scarcity of rich edit data. To address these problems, we propose neural diffusion models that operate on syntax trees of any context-free grammar. Similar to image diffusion models, our method also inverts ``noise'' applied to syntax trees. Rather than generating code sequentially, we iteratively edit it while preserving syntactic validity, which makes it easy to combine this neural model with search. We apply our approach to inverse graphics tasks, where our model learns to convert images into programs that produce those images. Combined with search, our model is able to write graphics programs, see the execution result, and debug them to meet the required specifications. We additionally show how our system can write graphics programs for hand-drawn sketches.

View on arXivView PDF

Code Implementations(1)

MIT

Diffusion on syntax trees for program synthesis

48533Python, Jupyter NotebookMay 25, 20242 years agoMIT

Similar Papers

Cite this paper

@article{kapur2026diffusion,
  title  = {Diffusion On Syntax Trees For Program Synthesis},
  author = {Shreyas Kapur and Erik Jenner and Stuart Russell},
  year   = {2026},
  eprint = {2405.20519},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2405.20519},
  journal = {ICLR 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2405.20519.svg)](https://codeofpaper.com/paper/2405.20519)

Discussion