Research notesLanguage models & structured learning
← All guides

Markup-to-image diffusion · ICLR 2023

Diffusion rendering: LaTeX formulas and SMILES molecule images

A diffusion model can learn to render a supplied LaTeX formula into a mathematical image, or a supplied SMILES string into a two-dimensional molecular structure image. Yuntian Deng, Noriyuki Kojima, and Alexander M. Rush introduced this approach in Markup-to-Image Diffusion Models with Scheduled Sampling, released on October 11, 2022 and published at ICLR 2023. Their learned renderer covers LaTeX mathematics, SMILES molecules, HTML table layouts, and LilyPond sheet music. Scheduled sampling trains the denoiser to correct errors in its own intermediate predictions.

Original research

Markup-to-Image Diffusion Models with Scheduled Sampling
Yuntian Deng, Noriyuki Kojima, Alexander M. Rush · ICLR 2023
Record and citation

Work through an example

Four structured inputs, four image domains

The original task learns the direction from markup to rendered image.

Mathematical formulas

\frac{a}{b} + c^2

LaTeX → formula image

Molecular drawings

CC(=O)O

SMILES → molecule image

Table layouts

<table>…</table>

HTML → table image

Sheet music

{ c'4 d' e' f' }

LilyPond → score image

Open the LaTeX rendering demo ↗

The four input examples illustrate the task formats. Generated outputs and experiments are in the original paper and repository.

How does a diffusion model render a LaTeX formula?

The input is LaTeX source code and the output is an image of the specified formula. For example, \frac{a}{b} + c^2 describes a fraction followed by a squared term. A learned renderer must place the numerator above the denominator and position the superscript correctly. In this task, diffusion is the image-generation method; the formula supplied to it defines the mathematical content.

The model learns this mapping from paired markup and rendered images, including the formula pairs in im2latex-100k. At inference, it conditions a sequence of image-denoising steps on the supplied markup. The denoiser turns image noise into the rendered pixels, learning the relationship between source tokens, symbols, and layout.

The same input-to-image formulation applies to HTML table layouts and LilyPond music notation. These domains make the dependencies concrete: a table cell must occupy its specified row and column, and a note must have the pitch and duration described by the source.

Sources: Markup-to-Image Diffusion Models with Scheduled Sampling

How does a SMILES string become a molecular drawing?

SMILES specifies the molecule through an atom-and-bond sequence. In SMILES-to-image rendering, that molecule is supplied as the input, and the diffusion model generates its two-dimensional structural drawing. For example, CC(=O)O specifies acetic acid; the drawing must preserve the stated atoms, single bonds, and carbon–oxygen double bond. This is a task-format example, with original model outputs available in the paper and code repository.

The molecular identity is fixed by the input SMILES. What the model learns is how to depict that structure in pixels. The Markup-to-Image experiments evaluate agreement with a reference drawing, connecting the generated image directly to the supplied symbolic description.

Sources: Markup-to-Image Diffusion Models with Scheduled Sampling

Watch the learned renderer denoise an image

These recorded trajectories come from the original repository’s Scheduled Sampling results. Each animation follows an image from noise to a rendered output.

Original code, generated examples, and reference images ↗

Sources: Markup-to-Image Diffusion Models with Scheduled Sampling

A plausible image is not enough

These images demand exact symbolic fidelity. An extra minus sign changes a formula; an incorrect bond changes a molecule; a shifted note changes a score. An image that resembles the right domain still fails when its symbols do not match the input. Layout errors also propagate: an extra symbol displaces what follows.

The paper therefore evaluates alignment with the reference rendering. Its primary metric treats binarized images as sequences of columns and uses dynamic time warping, with tolerance for small shifts. Pixel error and additional image-similarity metrics provide complementary measurements. The paper explicitly distinguishes these criteria from natural-image scores that emphasize visual fidelity and broad semantics.

Sources: Markup-to-Image Diffusion Models with Scheduled Sampling

Train the denoiser on its own intermediate states

Standard diffusion training constructs noisy inputs from ground-truth images. During sampling, the next denoising step instead receives the result of previous model predictions. Mistakes in those predictions change the states encountered later. The paper analyzes this mismatch as a sequential decision problem with compounding errors, connecting diffusion sampling to exposure bias.

Scheduled sampling changes the training inputs so that the denoiser encounters model-generated states and learns to correct its own errors. This adapts a principle previously studied in sequence generation to diffusion training. The experiments compare scheduled sampling with the baseline across all four rendering domains.

Sources: Markup-to-Image Diffusion Models with Scheduled Sampling

Inspect the original examples and implementation

The released repository includes side-by-side animations of scheduled sampling, the baseline, and ground truth for formulas, tables, music, and molecules. These examples expose the intermediate denoising trajectory.

For a new learned-rendering task, define paired source and target data, identify the symbolic errors that change meaning, and select metrics that expose them. The released resources include the original datasets, checkpoints, code, and recorded examples.

Sources: Markup-to-Image Diffusion Models with Scheduled Sampling

Papers & implementations

ICLR 2023

Markup-to-Image Diffusion Models with Scheduled Sampling

Yuntian Deng, Noriyuki Kojima, Alexander M. Rush

Learns to render LaTeX, HTML table layouts, LilyPond music notation, and SMILES molecules with conditional diffusion. Scheduled sampling exposes denoisers to their own generated inputs to address compounding errors.

The original diffusion-based markup-to-image method and four-domain rendering benchmark.

ACM Multimedia 2023

Contrast-augmented Diffusion Model with Fine-grained Sequence Alignment for Markup-to-Image Generation

Guojin Zhong, Jin Yuan, Pan Wang, Kailun Yang, Weili Guan, Zhiyong Li

FSA-CDM combines fine-grained cross-modal sequence alignment, contextual modeling, and a contrast-augmented diffusion objective for markup-to-image generation.

A subsequent markup-to-image method that builds on the task and four datasets introduced by Deng, Kojima, and Rush, addressing alignment and contrastive feedback.

ICML 2023

Input Perturbation Reduces Exposure Bias in Diffusion Models

Mang Ning, Enver Sangineto, Angelo Porrello, Simone Calderara, Rita Cucchiara

Studies accumulated sampling errors in diffusion models and trains with perturbed inputs to simulate inference-time prediction errors.

Addresses the same training–sampling mismatch with synthetic input perturbations; scheduled sampling trains on model-generated states.