DocSynthv2: A Practical Autoregressive Modeling for Document Generation

Sanket Biswas, Rajiv Jain, Vlad I. Morariu, Jiuxiang Gu, Puneet Mathur, Curtis Wigington, Tong Sun, Josep LladósarXiv 2024 · DOI

Introduction

Generating high-quality documents involves more than just spatial layout; it requires a deep integration of structure and content. While significant progress has been made in layout generation and large language models (LLMs) for text, combining these into a unified, high-resolution document generation framework remains a challenge. Researchers from Adobe and the Computer Vision Center (UAB) have introduced DocSynthv2, an autoregressive model that generates document layouts and textual content simultaneously.

The Challenge of Content-Aware Generation

Existing document generation approaches typically fall into two categories. Layout-only models predict bounding boxes for elements like titles or images but leave them as empty placeholders. Conversely, pixel-based models generate document images that often suffer from low resolution or "gibberish" text, making them unsuitable for editing or data extraction.

DocSynthv2 addresses the need for content-aware generation. In a structured document, text content often dictates the layout—for instance, a lengthy title requires a larger bounding box. By modeling layout and text together, DocSynthv2 ensures logical consistency between a document's structure and its content.

Methodology: Autoregressive Modeling with GPT-2

The core of DocSynthv2 is a transformer-based architecture that treats document generation as a sequence-to-sequence problem.

Document Serialization

To process 2D document structures within a 1D transformer, the model serializes each document element into a sequence of tokens. Each element is represented as: $$D = \{ \text{Category, } X, Y, W, H, \text{Text Content} \}$$ Continuous coordinates ($X, Y, W, H$) are converted into discrete tokens using 8-bit uniform quantization. This allows the model to predict spatial attributes using the same vocabulary as textual content. To handle missing data or variable-length sequences, the authors utilized a special [NULL] token, ensuring a consistent sequence structure.

DocSynthv2 Architecture and Serialization Scheme

Training and Inference

DocSynthv2 utilizes a standard autoregressive GPT-2 architecture. During training, the model learns to predict the next token in the sequence, effectively capturing the statistical relationships between element categories, their positions, and their textual content. For example, the model learns that a "Table" element is typically followed by "TableCell" sub-elements containing specific numeric or text data. This approach is lightweight as it avoids complex image encoders, allowing it to handle document sequences of varying lengths efficiently.

Datasets and Benchmarking

The model was evaluated on two distinct datasets:

  1. Crello: A collection of professional design templates for social media, ads, and banners.
  2. PubGenNet: A new large-scale benchmark introduced by the authors. It contains over 335,000 samples derived from the PubLayNet dataset, enriched with raw text and font attributes. This dataset provides a robust foundation for training models on complex scientific layouts and technical text.

Key Results and Insights

The researchers compared DocSynthv2 against state-of-the-art models such as Layoutformer++ and FlexDM.

  • Improved Structural Quality: A significant finding was that including text attributes improves layout generation. The model trained on both layout and text ("Ours (lay+txt)") outperformed layout-only versions in terms of alignment and overlap.
  • Quantitative Performance: On the PubGenNet dataset, DocSynthv2 achieved superior Alignment (0.015) and Overlap (0.0013) scores. In the Crello dataset, it outperformed FlexDM in text box placement, achieving a lower Bounding Box Error (BDE) of 0.131 compared to FlexDM's 0.141.
  • Qualitative Excellence: Visual evaluations demonstrate the model's ability to generate plausible titles and align them correctly with secondary text fields, such as addresses or dates, maintaining a logical flow between design and content.
Qualitative results on Crello (a) and PubGenNet (b) datasets

Conclusion and Future Directions

DocSynthv2 represents a practical step toward unified document generation. By leveraging a pure autoregressive decoder, it avoids the resolution constraints of pixel-based generative models. While the model excels at placement and basic content generation, future work involves integrating larger pre-trained LLMs to enhance text coherence and developing more sophisticated evaluation metrics that capture the aesthetic and functional utility of generated designs.

Summary updated

BibTeX
@misc{biswas2024docsynthv,
  author = {Sanket Biswas and Rajiv Jain and Vlad I. Morariu and Jiuxiang Gu and Puneet Mathur and Curtis Wigington and Tong Sun and Josep Lladós},
  title = {{DocSynthv2: A Practical Autoregressive Modeling for Document Generation}},
  year = {2024},
  eprint = {2406.08354},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.08354},
}
Figure