Markup-to-Image Diffusion Models with Scheduled Sampling

Yuntian Deng, Noriyuki Kojima, Alexander M Rush

In the rapidly evolving world of AI image generation, we are accustomed to seeing models conjure up "a cat in a hat" or "a sunset over Mars." These models excel in the fuzzy, creative space of natural language. But what happens when the input isn't a vague description, but a precise set of instructions like LaTeX code or an HTML snippet?

A team of researchers from Harvard and Cornell tackled this challenge in their paper, "Markup-to-Image Diffusion Models with Scheduled Sampling." They explore how to turn structured markup into perfectly rendered images using diffusion models, and in doing so, they identify—and fix—a critical flaw in how these models learn to generate complex, structured outputs.

The Challenge: Precision and Exposure Bias

Most text-to-image research focuses on generating realistic or artistic images conditioned on ambiguous natural language. This paper shifts the focus to markup-to-image generation, where the input (the markup) dictates exactly what the final image should look like.

While standard rule-based renderers already exist for these languages, a neural renderer offers unique advantages: it can be resilient to typos, handle a mix of natural and structured commands, and serve as a rigorous "unit test" for generative models. Because markup has a deterministic ground truth, it provides a controlled, compositional setting. It is much easier to quantify if a model "failed" to render a math formula than if it "failed" to paint a dog.

The core technical hurdle in this domain is exposure bias. In standard diffusion training, the model learns to predict the next step based on "perfect" ground-truth data with added noise. However, during inference, the model must rely on its own previous—and potentially imperfect—predictions. In structured tasks like rendering a math formula or a table, a tiny mistake (like misplacing a single symbol) can push the rest of the layout out of alignment, leading to a cascade of errors and a messy, incoherent final image.

The Solution: Scheduled Sampling

To address exposure bias, the authors use Denoising Diffusion Probabilistic Models (DDPM) as their foundation, utilizing a U-Net conditioned on text embeddings from pre-trained encoders (like GPT-Neo for general markup and ChemBERTa for molecules).

Crucially, they adapt Scheduled Sampling to the diffusion training process:

  • Standard Training: The model sees a noisy version of the ground truth and tries to predict the original image.
  • Scheduled Sampling Training: Instead of just adding noise to the ground truth, the model occasionally "rolls out" a few steps of its own generation process during training.

By seeing its own slightly-wrong intermediate predictions and being forced to correct them back toward the ground truth, the model learns to be robust to its own mistakes at test time. It learns the power of self-correction, specifically fixing the "hallucination" of duplicate or misplaced symbols.

Datasets and Key Results

The authors curated a suite of four diverse markup-to-image datasets to test compositional and relational properties:

  1. LaTeX-to-Math: Mathematical formulas.
  2. Table Layouts: HTML snippets containing nested <div> tags with borders and varying widths.
  3. Sheet Music: LilyPond markup.
  4. Molecules: SMILES strings rendered into 2D molecular diagrams.
HTML Table Layout Rendering

The researchers evaluated their models using standard metrics like RMSE and SSIM, alongside Dynamic Time Warping (DTW)—a metric that treats images as sequences of columns to measure alignment.

Scheduled sampling consistently outperformed standard diffusion across all datasets. On the Math dataset, the DTW score improved from 19.45 to 18.81. Qualitatively, the models produced clearly recognizable images for all domains. In the Table Layouts task, the generated images were often indistinguishable from the ground truth to the human eye. On the Math task, the best model's performance was roughly equivalent to taking a ground-truth image and removing three random symbols—a remarkably high bar for a purely data-driven renderer.

Limitations and the "Final Boss"

Despite the impressive progress, the models have not yet reached the 100% accuracy of traditional rule-based compilers. Long-range dependencies remain a significant hurdle.

LilyPond Sheet Music Rendering

Sheet music, in particular, remains the "final boss" of these datasets. Because LilyPond notes are often defined relative to previous notes, a single error early in the sequence can derail the entire score, testing the limits of the model's ability to maintain global coherence.

Moving forward, the authors suggest exploring more complex markups and investigating how these self-correction techniques might scale to larger, more general text-to-image models. By treating diffusion as a sequential decision-making process, this research opens new doors for improving the reliability and precision of generative AI.

Summary updated

BibTeX
@inproceedings{deng2023markup,
  author = {Yuntian Deng and Noriyuki Kojima and Alexander M Rush},
  title = {{Markup-to-Image Diffusion Models with Scheduled Sampling}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=81VJDmOE2ol},
}
Figure