DocDjinn: Controllable Synthetic Document Generation with VLMs and Handwriting Diffusion
Authors: Marcel Lamott, Saifullah Saifullah, Nauman Riaz, Yves-Noel Weweler, Tobias Alt-Veit, Ahmad Sarmad Ali, Muhammad Armaghan Shakir, Adrian Kalwa, Momina Moetesum, Andreas Dengel, Sheraz Ahmed, Faisal Shafait, Ulrich Schwanecke, Adrian Ulges
Organizations: RheinMain University of Applied Sciences, Wiesbaden, Germany · German Research Center for Artificial Intelligence, Kaiserslautern, Germany · DeepReader GmbH, Kaiserslautern, Germany · Insiders Technologies GmbH, Kaiserslautern, Germany · National University of Sciences and Technology (NUST), Islamabad, Pakistan
Effective document intelligence models rely on large amounts of annotated training data. However, procuring sufficient and high-quality data poses significant challenges due to the labor-intensive and costly nature of data acquisition. Additionally, leveraging language models to annotate real documents raises concerns about data privacy. Synthetic document generation has emerged as a promising, privacy-preserving alternative. We propose DocDjinn, a novel framework for controllable synthetic document generation using Vision-Language Models (VLMs) that produces annotated documents from unlabeled seed samples. Our approach generates visually plausible and semantically consistent synthetic documents that follow the distribution of an existing source dataset through clustering-based seed selection with parametrized sampling. By enriching documents with realistic diffusion-based handwriting and contextual visual elements via semantic-visual decoupling, we generate diverse, high-quality annotated synthetic documents. We evaluate across eleven benchmarks spanning key information extraction, question answering, document classification, and document layout analysis. To our knowledge, this is the first work demonstrating that VLMs can generate faithful annotated document datasets at scale from unlabeled seeds that can effectively enrich or approximate real, manually annotated data for diverse document understanding tasks. We show that with only 100 real training samples, our framework achieves on average 87% of the performance of the full real-world dataset. We publicly release our code and 140k+ synthetic document samples.
Figures & tables
Figure 1: Examples of synthetically generated documents across diverse domains and tasks. Our framework produces documents with realistic layouts, VLM-generated content, diffusion-based handwriting, and contextual visual elements.
Year
Name
Model
Target
Source
Text
HW
VE
U. GT.
Tasks
Max Res.
Dyn. Spec.
ML
OS
Editable
2017
DocCreator [ 31 ]
manual
full document
images
✓
✗
✗
✓
OCR / DLA
-
✗
✓
✓
✗
2019
Bui et al. [ 8 ]
GAN
document image
text
✓
✗
✗
✗
OCR
512×512
✗
✗
✗
✗
2021
Genalog [ 19 ]
templates
document image
text
✓
✗
✗
✗
NER
Unspec.
✗
✗
✓
✗
2021
DocSynth [ 5 ]
GAN
document image
layout
✗
✗
✓
✗
✗
128×128
✗
✗
✓
✓
2021
Raman et al. [ 47 ]
sampling
full document
layout
✓
✗
✓
✓
DLA
Unspec.
✗
✓
✗
✗
2022
SynthDoG [ 33 ]
sampling
full document
-
✓
✗
✗
✓
DLA
2560×1920
✗
✓
✓
✗
Table 1: Overview of recent synthetic document generation approaches compared to ours. Target specifies the generated modality, and Source the conditioning input. Text , HW , and VE indicate explicit support for readable text, readable handwritten text, and visual elements during generation. U. GT. represents the capability to automatically generate task annotations in an unsupervised manner. Max Res. denotes the maximum possible generation resolution, whereas Dyn. Spec. represents whether the generation process can be controlled via natural language. ML indicates multilingual generation ability, and OS indicates whether the framework is open source. Finally, Editable indicates whether generated documents are produced in an editable format (e.g., structured text) rather than as rasterized images.
Figure 2: Overview of DocDjinn for synthetic document generation. After selecting representative seeds from a source dataset, a VLM generates an HTML representation of the document, along with multi-task ground truth information. This representation is enhanced with diffusion-generated handwriting and further visual elements. Finally, the ground truth is updated with bounding boxes and verified.
Figure 3: Baseline alignment for sentence-level handwritten text. Top, left to right: input image, word segmentation, lowest-ink pixel per column (in red), and computed baseline via percentile (in blue). Bottom: example sentence-level handwritten text after baseline alignment (red).
Dataset
Smpl
α=0.50
α=0.75
α=1.00
Score ( ↑ )
LFID ( ↓ )
Score ( ↑ )
LFID ( ↓ )
Score ( ↑ )
LFID ( ↓ )
DocVQA
CC
62.46
7.60
61.51
7.49
63.16
7.52
DocVQA
IC
63.95
6.88
64.27
6.87
63.64
6.96
CORD
CC
55.62
37.31
57.03
36.95
57.74
36.75
CORD
IC
57.51
36.92
56.56
37.01
58.40
36.46
RVL-CDIP
CC
43.65
11.15
45.49
12.45
45.74
11.06
Table 2: Layout-FID (LFID) [ 21 ] and performance comparison for CC and IC sampling across different α values on LayoutLMv3 (VQA, KIE, CLS) and Faster R-CNN (DLA). Results averaged over 5 seeds (std <0.04 ).
Full
FewA
FewB
Δ
Model
Dataset
Task
Metric ( ↑ )
R
S
R+S
R
R+S
R
R+S
Full−FewB
R−S
BERT
DocVQA
VQA
ANLS
57.97
52.92
61.33
46.63
55.45
25.61
54.04
3.93
5.05
LiLT
DocVQA
VQA
ANLS
70.50
64.34
72.53
58.99
66.95
38.59
64.11
6.39
6.16
LayoutLMv3
DocVQA
VQA
ANLS
71.45
66.03
73.26
62.91
68.04
43.61
65.82
5.63
5.42
BERT
DocVQA-HW
VQA
ANLS
48.24
42.26
51.19
40.94
44.07
26.47
42.72
5.51
5.97
LiLT
DocVQA-HW
VQA
ANLS
58.94
50.26
58.24
50.21
50.95
35.88
50.78
8.16
8.67
Table 3: Performance across datasets and tasks with three training settings: (1) Full : models trained on all real (R), all synthetic (S), or both (R+S); (2) FewA : 300 – 1000 real samples with/without synthetic augmentation; (3) FewB : 100 real samples with/without synthetic augmentation. Gap columns ( Δ ) report: RFull−(R+S)FewB (how close 100 augmented samples approaches full training) and RFull−SFull (real vs synthetic quality). Bold indicates best per setting (std <0.02 ). Synthetic augmentation achieves +12.38 average improvement in FewB scenarios.
Dataset
Method
Task
FID ( ↓ )
LayoutFID ( ↓ )
DocVQA
Ours
VQA
41.36
6.96
WTQ
Ours
VQA
52.43
3.13
DocGenie [ 21 ]
KIE
155.34
31.30
CORD
Ours
KIE
139.52
36.46
FUNSD
Ours
KIE
44.57
9.60
KLC
Ours
KIE
26.98
7.98
Table 4: FID [ 24 ] and Layout-FID [ 21 ] scores comparing our method to prior work. Lower scores indicate better distributional similarity to real documents. Resolution annotations indicate synthesis resolution before upscaling for evaluation.
Appendix figures & tables37 assets
Supplementary material from the paper’s appendix.
Appendix
Pipeline Success (%)
Quality
Dataset
Task
VLM
GT
SP
Vis
FID ↓
LFID ↓
N
Claude
92.6
92.2
95.9
45.9
7.0
6864
DocVQA
VQA
Gemma
69.48
0.2
73.47
73.9
9.4
6864
Claude
95.5
95.5
93.5
51.2
9.6
140
FUNSD
KIE
Gemma
71.9
0.0
71.1
83.2
11.2
134
Claude
91.6
97.1
98.6
93.5
10.6
850
Appendix
Table 5: Claude vs. Gemma 3 27B comparison. Pipeline Success : GT = valid annotations, SP = single-page renders, Vis = valid visual element and handwriting definitions (documents without handwriting/visual elements are counted as valid). Quality : FID/LFID (Layout-FID) computed on N samples (lower = better).
Dataset
Train
Validation
Test
Train (Synth)
DocVQA [ 38 ]
10194
1286
1287
8082
DocVQA-HW
N/A
N/A
103
N/A
WTQ [ 43 ]
1350
337
421
1479
SROIE [ 29 ]
626
N/A
347
1008
FUNSD [ 30 ]
149
N/A
50
259
CORD [ 42 ]
800
100
100
1182
Appendix
Table 6: Train/validation/test splits and synthetic training sets for all datasets used in our experiments. For datasets with no validation set, we use 5% of the training set as the validation set.
Embedding
κ
Rank Score ↑
combined
10
74
combined
5
72
sentence
5
65
clip
5
56
clip
10
55
sentence
10
51
Appendix
Table 7: Clustering configurations ranked using cumulative position scores over our base datasets.
Dataset
Embedding
κ
Num Clusters
Silhouette Score ↑
Norm. Entropy ↑
Final Score ↑
SROIE
combined
10
14
0.64
0.94
0.79
ICDAR2019
clip
5
9
0.64
0.82
0.73
WTQ
combined
5
50
0.41
0.95
0.68
CORD
combined
10
22
0.39
0.96
0.68
Tobacco3482
combined
10
31
0.42
0.93
0.67
DocLayNet
combined
10
48
0.51
0.82
0.66
Appendix
Table 8: Metrics of the selected clusterings for all datasets (top) and listing of all clusterings for DocVQA (bottom), where we used combined embeddings and κ=10 for our experiments.
Figure 4: Overview of our used clusters for all datasets. Each clustering lists embedding type, HDBSCAN [ 10 ] minimum cluster size κ and number of resulting clusters.
Figure 5: Clustering results across different embeddings and HDBSCAN [ 10 ] minimum cluster sizes κ for DocVQA [ 38 ] .
Figure 6: Diffusion-based handwriting generation and baseline alignment. (a) The model synthesizes the full sentence “Quick Brown Fox Jumps Over 342 Lazy Dogs” with a coherent global baseline. (b) For each word segment, we estimate a robust baseline which is then used to compose the globally aligned line.
Figure 7: Baseline-aligned handwriting synthesis. The figure shows multiple handwriting segments generated by our latent diffusion model. Individually synthesized words, each with an automatically estimated baseline and composition of these word segments into globally baseline-aligned sentences, demonstrating consistent geometric structure across words and lines.
Figure 8: Image bank for visual elements of type figure , generated with Gemini 2.5 Flash [ 11 ] .
Figure 9: Image bank for visual elements of type logo , generated with Gemini 2.5 Flash [ 11 ] .
Figure 10: Image bank for visual elements of type photo , generated with Gemini 2.5 Flash [ 11 ] (top). Synthetic faces (bottom) generated with StyleGAN2 [ 32 ] via ThisPersonDoesNotExist.com.
Figure 20: DocLayNet-DLA [ 44 ] synthetic dataset samples for DLA task.
Figure 21: ICDAR2019 [ 18 ] synthetic dataset samples for DLA task.
Figure 22: PubLayNet [ 60 ] synthetic dataset samples for DLA task.
Embedding Type
Min. Cluster Size
Total Samples
Total Valid Samples
Input Tokens (M)
Output Tokens (M)
Cost (USD)
Avg. Words
Avg. HW Elems
Avg. Visual Elems
Task
Dataset Name
CLASSIFICATION
DocLayNet-CLS [ 44 ]
comb
10
4494
3978
4.08
7.48
124
407
0.052
0.334
RVL-CDIP [ 22 ]
comb
10
4441
3823
5.16
5.34
96
206
1.466
0.371
Tobacco3482 [ 34 ]
comb
10
5292
4092
6.24
6.49
116
251
2.042
0.435
DLA
DocLayNet-DLA [ 44 ]
comb
10
4502
3732
2.95
7.28
114
372
0.061
0.301
ICDAR2019 [ 18 ]
img
5
1594
1515
2.01
2.89
49
297
0.004
0.048
Appendix
Table 9: Overview of the final synthesized datasets using sampling strategy (v2) and sampling strength ( α=1 ) in our experiments. For each dataset, we report the embedding type (image-only or image+text), clustering and sampling parameters, total and valid sample counts, token usage, estimated generation cost, and average text/visual content statistics.
Embedding Type
Min. Cluster Size
Sample Strategy
Sample Alpha
Total Samples
Total Valid Samples
Input Tokens (M)
Output Tokens (M)
Cost (USD)
Avg. Words
Avg. HW Elems
Avg. Visual Elems
Task
Dataset Name
CLASSIFICATION
RVL-CDIP [ 22 ]
comb
10
v1
1
4500
3853
5.04
5.28
95
211
1.305
0.397
RVL-CDIP [ 22 ]
comb
10
v1
0.75
4306
3860
4.82
5.08
91
212
1.257
0.415
RVL-CDIP [ 22 ]
comb
10
v1
0.5
4491
3997
5.03
5.32
96
209
1.24
0.414
RVL-CDIP [ 22 ]
comb
10
v2
1
4441
3823
5.16
5.34
96
206
1.466
0.371
RVL-CDIP [ 22 ]
comb
10
v2
0.75
4329
3891
5.04
5.25
94
210
1.446
0.411
Appendix
Table 10: Ablation variants generated by varying the sampling strategy (v1/v2) and sampling strength ( α ). The table reports the same statistics as Table 9 , enabling comparison of how sampling choices impact dataset size, token usage, and content composition.
Figure 23: Comparison between real and synthetic data for DocVQA [ 38 ] (a-b) and WTQ [ 43 ] (c-d). UMAP embeddings (a, c) show semantic distributions of questions, while bar charts (b, d) compare question type frequencies across datasets.
Figure 24: Comparisons of class distributions between real and synthetic data for RVL-CDIP [ 22 ] (a), Tobacco3482 [ 34 ] (b) and DocLayNet-CLS [ 44 ] (c).
Figure 25: Heatmaps comparing entity placement by type between real and synthetic for CORD [ 42 ] .
Figure 26: Heatmaps comparing entity placement by type between real and synthetic data for FUNSD [ 30 ] (a) and SROIE [ 29 ] (b).
Figure 27: Comparison of entity type distributions between real and synthetic KIE datasets.
Figure 28: DocLayNet-DLA [ 44 ] GT (left) compared to predictions of Faster R-CNN [ 49 ] trained on purely synthetic data (right). Poor performance likely caused by definitional mismatches in list-item classification (distance-based vs. semantic).
Figure 29: DocLayNet-DLA [ 44 ] GT (left) compared to predictions of Faster R-CNN [ 49 ] trained on purely synthetic data (right). Poor performance likely caused by insufficient variety in visual elements to capture complex images with embedded text.
Figure 30: DocLayNet-DLA [ 44 ] GT (left) compared to predictions of Faster R-CNN [ 49 ] trained on purely synthetic data (right). Poor performance likely caused by limited table diversity in size and structure in our synthetic data. Our model fails to annotate the region as a single table.
Figure 31: DocLayNet-DLA [ 44 ] GT (left) compared to predictions of Faster R-CNN [ 49 ] trained on purely synthetic data (right). Poor performance likely caused by insufficient detailed GT specification. Real GT annotates the formulas as "Picture", while our model annotates them as "Formula".
Figure 32: Comparison of annotation spatial heatmaps and class distributions for real and synthetic versions of ICDAR2019 [ 18 ] (a, b) and PubLayNet [ 60 ] (c, d).
Figure 33: Comparison of annotation spatial heatmaps (top) and class distributions (bottom) for real and synthetic versions of DocLayNet-DLA [ 44 ] .
Task
Model
Modality
Learning Rate
Batch Size
Epochs
Optimizer
Weight Decay
Momentum
Warmup Ratio
Dropout
Segment-Level Layout
Early Stopping
Mixed Precision
Image Size
BERT [ 13 ]
T
1.00E-05
32
50
Adam
0.01
N/A
0.1
0.1
✗
✓
✗
N/A
LiLT [ 58 ]
T+L
1.00E-05
32
50
Adam
0.01
N/A
0.1
0.1
✗
✓
✗
N/A
CLS
LayoutLMv3 [ 28 ]
T+L+I
1.00E-05
32
50
Adam
0.01
N/A
0.1
0.1
✓
✓
✗
224×224
BERT [ 13 ]
T
2.00E-05
16
100
AdamW
0.01
N/A
0.1
0.1
✗
✗
✗
N/A
LiLT [ 58 ]
T+L
2.00E-05
16
100
AdamW
0.01
N/A
0.1
0.1
✗
✗
✗
N/A
KIE
LayoutLMv3 [ 28 ]
T+L+I
2.00E-05
16
100
AdamW
0.01
N/A
0.1
0.1
✓
✗
✗
224×224
Appendix
Table 11: Default training hyperparameters for all models and tasks in our experiments. For each task (CLS, KIE, VQA, DLA) and model combination, we report learning rate, batch size, number of epochs, optimizer settings, and other training parameters. These settings were chosen based on preliminary experiments and common practices for document understanding tasks.
Document generation has gained growing attention in the field of AI-driven content creation. In this work, we push its boundaries by introducing AnyDoc, a framework capable of handling multiple generation tasks across a wide spectrum of document categories, all represented in a unified HTML/CSS format. To overcome the limited coverage and scale of existing human-crafted document datasets, AnyDoc first establishes a scalable data synthesis pipeline to automatically generate documents in HTML/CSS form. This pipeline yields DocHTML, a large-scale dataset containing 265,206 document samples, while spanning 111 categories and 32 distinct styles. Additionally, all documents are equipped with comprehensive metadata, including design intentions, HTML/CSS source code, visual assets, and rendered screenshots. Building on the curated dataset, AnyDoc fine-tunes multi-modal large language models (MLLMs) to achieve three practical document generation tasks: intention-to-document, document derendering, and element-to-document. To address the content overflow issue observed during fine-tuning, AnyDoc further incorporates a height-aware reinforcement learning (HARL) post-training procedure. By defining a reward function based on the difference between predicted and target document heights, overflow is penalized and gradually mitigated during HARL, thereby enhancing overall performance. Qualitative and quantitative experiments demonstrate that AnyDoc outperforms both general-purpose MLLMs and task-specific baselines across all three tasks.
Large language models (LLMs) have emerged as a powerful tool for synthetic data generation. A particularly important use case is producing synthetic replicas of private text, which requires carefully balancing privacy and utility. We propose Realistic and Privacy-Preserving Synthetic Data Generation (RPSG), which uses private seeds and integrates privacy-preserving strategies, including a formal differential privacy (DP) mechanism in the candidate selection, to generate realistic synthetic data. Comprehensive experiments against state-of-the-art private synthetic data generation methods demonstrate that RPSG achieves high fidelity to private data while providing strong privacy protection.
Qian Ma, Sarah Rajtmajer
Information Sciences and Technology, The Pennsylvania State University
Synthetic data is a standard component in training large language models, yet systematic comparisons across design dimensions, including rephrasing strategy, generator model, and source data, remain absent. We conduct extensive controlled experiments, generating over one trillion tokens, to identify critical factors in rephrasing web text into synthetic pretraining data. Our results reveal that structured output formats, such as tables, math problems, FAQs, and tutorials, consistently outperform both curated web baselines and prior synthetic methods. Notably, increasing the size of the generator model beyond 1B parameters provides no additional benefit. Our analysis also demonstrates that the selection of the original data used for mixing substantially influences performance. By applying our findings, we develop FinePhrase, a 486-billion-token open dataset of rephrased web text. We show that FinePhrase outperforms all existing synthetic data baselines while reducing generation costs by up to 30 times. We provide the dataset, all prompts, and the generation framework to the research community.
Joel Niklaus, Atsuki Yamaguchi, Michal Štefánik +9
Hugging Face · University of Sheffield, United Kingdom · National Institute of Informatics, Japan