FlexDoc: Parameterized Sampling for Diverse Multilingual Synthetic Documents for Training Document Understanding Models

Karan Dua, Hitesh Laxmichand Patel, Puneet Mittal, Ranjeet Gupta, Amit Agarwal, Praneet Pabolu, Srikant Panda, Hansa Meghwani, Graham Horwood, Fahad Shah · DOI

Introduction

Document Understanding (DU) is a critical multimodal challenge in artificial intelligence, requiring models to simultaneously process text, visual styling, and spatial layout to extract structured information from documents like invoices, receipts, and forms. Despite the advancement of transformer-based architectures, the primary bottleneck in the field remains data scarcity. Collecting real-world business documents is fraught with legal hurdles, including GDPR compliance and privacy restrictions, while manual annotation is prohibitively expensive and time-consuming.

Existing synthetic data generation methods often rely on "hard templates"—static layouts where only specific text fields are swapped. These methods are brittle and fail to capture the "wild" structural variety encountered in real-world scenarios. This paper introduces FlexDoc, a framework designed to generate massive, diverse, and multilingual synthetic document datasets by replacing rigid templates with probabilistic sampling and a dynamic layout engine.

The FlexDoc Framework

FlexDoc shifts the paradigm from fixed templates to Stochastic Schemas. This approach treats document generation as a probabilistic process, allowing for the creation of thousands of unique variants from a single underlying definition.

1. Stochastic Schemas and Parameterized Sampling

Instead of a fixed layout, a document is defined via a JSON schema where every attribute—including font choice, color, field presence, and the number of rows in a table—is a random variable. The Parameterized Sampling algorithm then "freezes" these variables into a specific permutation, ensuring that every generated document is unique while adhering to the logical constraints of the document type.

2. Dynamic Virtual Grid Algorithm

A core innovation of FlexDoc is the Dynamic Virtual Grid. To avoid the unrealistic appearance of random text placement, the algorithm treats the page as a flexible grid. It dynamically adjusts row and column dimensions based on the sampled content, ensuring that elements are structured and aligned—mimicking human design logic—without being confined to a pre-defined coordinate system. This prevents text overlap and maintains visual coherence across diverse layouts.

3. Multilingualism and Automated Rendering

FlexDoc achieves multilingual support by integrating the Faker library for entity generation and machine translation for headers and labels. This allows the system to generate documents in various languages (e.g., Spanish, Portuguese, English) using the same structural logic. The final output is rendered using the Pillow library, which simultaneously produces pixel-perfect bounding box annotations and labels, eliminating the need for human verification.

Experimental Results

The researchers evaluated FlexDoc by augmenting several industry-standard benchmarks, including DocILE (business documents), IDSEM (Spanish electricity invoices), and SROIE (receipts).

Performance Gains

The impact of FlexDoc-generated data on model performance was significant:

  • DocILE Benchmark: Adding 5,000 FlexDoc samples to the training set improved the F1 score of a LayoutLM model by 10.2% (from 72.7% to 82.9%).
  • Large Language Models: For the Phi-4-Multimodal model, the performance jump reached 11%.

Efficiency and Diversity

FlexDoc demonstrated a massive reduction in human labor. In a head-to-head comparison with traditional hard-template methods, FlexDoc reduced the human effort required for data preparation from 1,500 minutes to just 150 minutes—a 90% reduction in cost. Furthermore, embedding-based similarity metrics confirmed that FlexDoc-generated documents possess a level of structural diversity comparable to real-world datasets, preventing models from overfitting to specific visual patterns.

Discussion and Future Work

FlexDoc proves that layout diversity is king in training robust DU models. By providing a mechanism to scale the "long tail" of document structures—such as invoices with unusual line-item counts or missing fields—FlexDoc allows models to generalize far better than those trained on real data alone.

However, the authors identify several areas for improvement:

  • Semantic Logic: Currently, numerical values in generated documents (e.g., line items in an invoice) may not mathematically sum to the total. Future iterations will include "semantic value generators" to ensure internal consistency.
  • Complex Backgrounds: While highly effective for semi-structured business documents, FlexDoc currently struggles with high-fidelity backgrounds found in documents like passports or driver's licenses, where hard templates remain more effective.
  • Cultural Nuance: Future work will aim to incorporate regional document conventions to better reflect how structural norms differ between countries (e.g., German vs. Japanese invoice layouts).

Summary updated

BibTeX
@misc{dua2025flexdoc,
  author = {Karan Dua and Hitesh Laxmichand Patel and Puneet Mittal and Ranjeet Gupta and Amit Agarwal and Praneet Pabolu and Srikant Panda and Hansa Meghwani and Graham Horwood and Fahad Shah},
  title = {{FlexDoc: Parameterized Sampling for Diverse Multilingual Synthetic Documents for Training Document Understanding Models}},
  year = {2025},
  eprint = {2510.02133},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.02133},
}
Figure