Diffusion-based Document Layout Generation

Liu He, Yijuan Lu, John Corring, Dinei A. F. Florêncio, Cha Zhang · DOI

Abstract

Document layout generation requires sophisticated spatial reasoning to ensure that text, images, and tables are organized in a manner that is both aesthetically pleasing and functionally readable. This paper introduces a novel approach to this challenge by applying discrete sequence diffusion models. By representing layout elements as a sequence of coordinates and categories, the proposed model achieves state-of-the-art realism and alignment across diverse datasets. Furthermore, the authors introduce Doc-EMD, a robust new metric for evaluating document similarity based on Earth Mover’s Distance, providing a more mathematically sound alternative to existing evaluation methods.

Introduction

Creating professional document layouts is a complex task involving the coordination of various structural elements. A successful layout must balance visual hierarchy with functional readability. Existing generative models for layouts, however, face several significant hurdles. Generative Adversarial Networks (GANs), such as LayoutGAN, often struggle with variable-length documents and frequently produce unrealistic element overlaps. Conversely, autoregressive models like Layout Transformers generate layouts token-by-token, which can lead to "drift"—a phenomenon where later elements fail to align with the global structure established by earlier ones.

Additionally, the field lacks standardized, open-source metrics for evaluation. Current metrics like DocSim are often poorly normalized or fail to capture structural similarities intuitively. This research addresses these gaps by providing a stable generative framework based on diffusion and a mathematically grounded metric to measure layout quality.

Methodology

Discrete Diffusion for Layouts

The researchers adapt Diffusion Probabilistic Models—the technology underlying state-of-the-art image generators—to structured document data. In this framework, a layout is represented as a sequence of 5-tuples: (class, x, y, width, height). These tuples are flattened into a single discrete sequence.

Since coordinates and categories are discrete tokens, the authors employ a "rounding and embedding" approach. Discrete tokens are mapped into a continuous embedding space where Gaussian noise is added during the "forward" diffusion process. A Transformer-based model is then trained to reverse this noise. Finally, a rounding module maps the denoised embeddings back into valid discrete layout tokens. Unlike autoregressive models, this diffusion approach allows for global refinement, as the model refines the entire layout simultaneously rather than committing to one element at a time.

The Doc-EMD Metric

To address evaluation gaps, the authors propose the Document Earth Mover’s Distance (Doc-EMD). Unlike traditional metrics that focus solely on coordinate overlaps, Doc-EMD treats layout boxes as point densities. It calculates the "cost" of transforming one layout into another by matching elements of the same class. This metric obeys the triangle inequality and is significantly better at differentiating between complex structural designs, such as single-column versus multi-column layouts.

Experimental Setup

The model was evaluated on three major benchmarks representing different levels of complexity:

  1. PubLayNet: Approximately 330,000 layouts of academic papers featuring five categories (Text, Title, List, Figure, Table).
  2. DocBank: Approximately 500,000 layouts from arXiv with 12 fine-grained categories (Abstract, Author, Footer, etc.).
  3. Magazine: A smaller, more complex dataset of approximately 4,000 layouts characterized by high overlap and diverse designs.

Results and Discussion

Quantitative Performance

On the PubLayNet dataset, the diffusion-based model achieved a DocSim of 0.163 (higher is better) and a Doc-EMD of 0.053 (lower is better). These results outperform both LayoutVAE and Layout Transformer, establishing a new state-of-the-art for layout generation. Ablation studies indicated that 2,000 diffusion steps provided the optimal balance between generation quality and computational efficiency.

Alignment and Realism

Qualitative analysis demonstrates that the model is superior at maintaining the "gutters" and columns typical of professional academic papers. While competing models often produce "shaky" or misaligned boxes, the diffusion approach ensures sharp alignment and fewer impossible overlaps due to its global refinement process.

Downstream Utility

To demonstrate the practical utility of the generated layouts, the authors used them to create synthetic document images for training a layout detector (Faster R-CNN). The detector trained on these synthetic layouts achieved a 0.795 mAP, outperforming the previous state-of-the-art synthetic generator (VTN), which achieved 0.769 mAP. This suggests that the generated layouts are realistic enough to serve as effective training data for other computer vision tasks.

Conclusion and Future Work

This work demonstrates that discrete sequence diffusion models are highly effective for document layout generation, offering superior alignment and structural integrity compared to autoregressive or GAN-based methods. The introduction of Doc-EMD further provides the community with a more reliable tool for layout evaluation.

Future research will focus on conditional generation—enabling the model to generate layouts based on specific text content—and expanding the pipeline to handle full OCR generation at the line level for complete document synthesis.

Summary updated

BibTeX
@inproceedings{he2023diffusion,
  author = {Liu He and Yijuan Lu and John Corring and Dinei A. F. Florêncio and Cha Zhang},
  title = {{Diffusion-based Document Layout Generation}},
  booktitle = {ICDAR},
  year = {2023},
  url = {https://openreview.net/forum?id=6cTrDZrxeO},
}
Figure