seed-data 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. seed_data-0.0.1/LICENSE +175 -0
  2. seed_data-0.0.1/NOTICE +1 -0
  3. seed_data-0.0.1/PKG-INFO +492 -0
  4. seed_data-0.0.1/README.md +451 -0
  5. seed_data-0.0.1/pyproject.toml +100 -0
  6. seed_data-0.0.1/setup.cfg +4 -0
  7. seed_data-0.0.1/src/doc_gen_agent/__init__.py +24 -0
  8. seed_data-0.0.1/src/doc_gen_agent/__main__.py +104 -0
  9. seed_data-0.0.1/src/doc_gen_agent/augment.py +258 -0
  10. seed_data-0.0.1/src/doc_gen_agent/batch.py +213 -0
  11. seed_data-0.0.1/src/doc_gen_agent/cli.py +27 -0
  12. seed_data-0.0.1/src/doc_gen_agent/critique.py +147 -0
  13. seed_data-0.0.1/src/doc_gen_agent/nodes.py +53 -0
  14. seed_data-0.0.1/src/doc_gen_agent/orchestrate.py +447 -0
  15. seed_data-0.0.1/src/doc_gen_agent/packet.py +785 -0
  16. seed_data-0.0.1/src/doc_gen_agent/packets/insurance-claim-packet/packet.json +34 -0
  17. seed_data-0.0.1/src/doc_gen_agent/packets/lending-package/packet.json +78 -0
  18. seed_data-0.0.1/src/doc_gen_agent/prompts/__init__.py +17 -0
  19. seed_data-0.0.1/src/doc_gen_agent/prompts/aug_critic.j2 +37 -0
  20. seed_data-0.0.1/src/doc_gen_agent/prompts/augmentor.j2 +51 -0
  21. seed_data-0.0.1/src/doc_gen_agent/prompts/critic.j2 +14 -0
  22. seed_data-0.0.1/src/doc_gen_agent/prompts/critic_vision.j2 +94 -0
  23. seed_data-0.0.1/src/doc_gen_agent/prompts/data_critic.j2 +21 -0
  24. seed_data-0.0.1/src/doc_gen_agent/prompts/data_generator.j2 +55 -0
  25. seed_data-0.0.1/src/doc_gen_agent/prompts/doc_generator.j2 +102 -0
  26. seed_data-0.0.1/src/doc_gen_agent/prompts/doc_generator_html.j2 +123 -0
  27. seed_data-0.0.1/src/doc_gen_agent/schemas/bank-statement/generation_guidance.md +53 -0
  28. seed_data-0.0.1/src/doc_gen_agent/schemas/bank-statement/schema.json +116 -0
  29. seed_data-0.0.1/src/doc_gen_agent/schemas/cable-bill/generation_guidance.md +90 -0
  30. seed_data-0.0.1/src/doc_gen_agent/schemas/cable-bill/samples/README.md +37 -0
  31. seed_data-0.0.1/src/doc_gen_agent/schemas/cable-bill/schema.json +201 -0
  32. seed_data-0.0.1/src/doc_gen_agent/schemas/commercial-lease/generation_guidance.md +45 -0
  33. seed_data-0.0.1/src/doc_gen_agent/schemas/commercial-lease/schema.json +89 -0
  34. seed_data-0.0.1/src/doc_gen_agent/schemas/credit-report/generation_guidance.md +60 -0
  35. seed_data-0.0.1/src/doc_gen_agent/schemas/credit-report/schema.json +218 -0
  36. seed_data-0.0.1/src/doc_gen_agent/schemas/employment-verification-letter/generation_guidance.md +44 -0
  37. seed_data-0.0.1/src/doc_gen_agent/schemas/employment-verification-letter/schema.json +129 -0
  38. seed_data-0.0.1/src/doc_gen_agent/schemas/fcc-invoice/generation_guidance.md +61 -0
  39. seed_data-0.0.1/src/doc_gen_agent/schemas/fcc-invoice/samples/README.md +37 -0
  40. seed_data-0.0.1/src/doc_gen_agent/schemas/fcc-invoice/schema.json +182 -0
  41. seed_data-0.0.1/src/doc_gen_agent/schemas/homeowners-insurance-declaration/generation_guidance.md +63 -0
  42. seed_data-0.0.1/src/doc_gen_agent/schemas/homeowners-insurance-declaration/schema.json +160 -0
  43. seed_data-0.0.1/src/doc_gen_agent/schemas/insurance-claim/generation_guidance.md +38 -0
  44. seed_data-0.0.1/src/doc_gen_agent/schemas/insurance-claim/schema.json +115 -0
  45. seed_data-0.0.1/src/doc_gen_agent/schemas/invoice/generation_guidance.md +55 -0
  46. seed_data-0.0.1/src/doc_gen_agent/schemas/invoice/schema.json +161 -0
  47. seed_data-0.0.1/src/doc_gen_agent/schemas/loan-application/generation_guidance.md +59 -0
  48. seed_data-0.0.1/src/doc_gen_agent/schemas/loan-application/schema.json +195 -0
  49. seed_data-0.0.1/src/doc_gen_agent/schemas/medical-discharge/generation_guidance.md +32 -0
  50. seed_data-0.0.1/src/doc_gen_agent/schemas/medical-discharge/schema.json +100 -0
  51. seed_data-0.0.1/src/doc_gen_agent/schemas/pay-stub/generation_guidance.md +57 -0
  52. seed_data-0.0.1/src/doc_gen_agent/schemas/pay-stub/schema.json +166 -0
  53. seed_data-0.0.1/src/doc_gen_agent/schemas/police-report/generation_guidance.md +36 -0
  54. seed_data-0.0.1/src/doc_gen_agent/schemas/police-report/schema.json +148 -0
  55. seed_data-0.0.1/src/doc_gen_agent/schemas/property-appraisal/generation_guidance.md +59 -0
  56. seed_data-0.0.1/src/doc_gen_agent/schemas/property-appraisal/schema.json +185 -0
  57. seed_data-0.0.1/src/doc_gen_agent/schemas/statement-of-work/generation_guidance.md +126 -0
  58. seed_data-0.0.1/src/doc_gen_agent/schemas/statement-of-work/schema.json +154 -0
  59. seed_data-0.0.1/src/doc_gen_agent/schemas/title-report/generation_guidance.md +59 -0
  60. seed_data-0.0.1/src/doc_gen_agent/schemas/title-report/schema.json +189 -0
  61. seed_data-0.0.1/src/doc_gen_agent/schemas/w2/generation_guidance.md +51 -0
  62. seed_data-0.0.1/src/doc_gen_agent/schemas/w2/schema.json +156 -0
  63. seed_data-0.0.1/src/doc_gen_agent/session.py +12 -0
  64. seed_data-0.0.1/src/doc_gen_agent/tools.py +127 -0
  65. seed_data-0.0.1/src/doc_gen_agent/utils.py +91 -0
  66. seed_data-0.0.1/src/seed_data.egg-info/PKG-INFO +492 -0
  67. seed_data-0.0.1/src/seed_data.egg-info/SOURCES.txt +72 -0
  68. seed_data-0.0.1/src/seed_data.egg-info/dependency_links.txt +1 -0
  69. seed_data-0.0.1/src/seed_data.egg-info/entry_points.txt +2 -0
  70. seed_data-0.0.1/src/seed_data.egg-info/requires.txt +22 -0
  71. seed_data-0.0.1/src/seed_data.egg-info/top_level.txt +1 -0
  72. seed_data-0.0.1/tests/test_packet.py +380 -0
  73. seed_data-0.0.1/tests/test_subgraph.py +160 -0
  74. seed_data-0.0.1/tests/test_unit.py +208 -0
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
seed_data-0.0.1/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,492 @@
1
+ Metadata-Version: 2.4
2
+ Name: seed-data
3
+ Version: 0.0.1
4
+ Summary: AI-powered synthetic document generation pipeline for benchmarking document extraction (IDP/KIE) systems
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/awslabs/synthetically-engineered-evaluation-data
7
+ Project-URL: Repository, https://github.com/awslabs/synthetically-engineered-evaluation-data
8
+ Project-URL: Documentation, https://awslabs.github.io/synthetically-engineered-evaluation-data/
9
+ Project-URL: Issues, https://github.com/awslabs/synthetically-engineered-evaluation-data/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Scientific/Engineering
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: NOTICE
19
+ Requires-Dist: strands-agents
20
+ Requires-Dist: strands-agents-tools
21
+ Requires-Dist: reportlab
22
+ Requires-Dist: weasyprint
23
+ Requires-Dist: pillow
24
+ Requires-Dist: python-dotenv
25
+ Requires-Dist: boto3
26
+ Requires-Dist: jinja2
27
+ Requires-Dist: augraphy
28
+ Requires-Dist: pypdfium2
29
+ Requires-Dist: pypdf
30
+ Requires-Dist: opencv-python
31
+ Requires-Dist: pyyaml
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: ruff; extra == "dev"
35
+ Requires-Dist: mkdocs; extra == "dev"
36
+ Requires-Dist: mkdocs-material; extra == "dev"
37
+ Requires-Dist: mkdocs-awesome-nav; extra == "dev"
38
+ Requires-Dist: mkdocstrings-python; extra == "dev"
39
+ Requires-Dist: pymdown-extensions; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # Synthetically Engineered Evaluation Data (SEED)
43
+
44
+ AI-powered synthetic document generation pipeline built on the [Strands Agents SDK](https://strandsagents.com/). Produces realistic PDF documents from JSON schemas, validates them through multi-stage critique loops, and optionally applies image augmentation to simulate real-world scanning/faxing artifacts. Each document is paired with a ground-truth JSON label, so the output is a ready-made benchmark set.
45
+
46
+ Designed for building evaluation datasets for document understanding systems: OCR, Key Information Extraction (KIE), and document classification. The pipeline is invoked as a Python module (`python -m doc_gen_agent`) or through the batch and packet scripts.
47
+
48
+ > **Not a production-ready solution.** This asset represents a proof-of-value
49
+ > for the services included and is not intended as a production-ready solution.
50
+ > You must determine how the [AWS Shared Responsibility Model](https://aws.amazon.com/compliance/shared-responsibility-model/)
51
+ > applies to your specific use case and implement the controls needed to achieve
52
+ > your desired security outcomes. AWS offers a broad set of security tools and
53
+ > configurations to enable our customers.
54
+ >
55
+ > Ultimately it is your responsibility as the developer of a full-stack
56
+ > application to ensure all of its aspects are secure. We provide security best
57
+ > practices in the repository documentation and a secure baseline, but Amazon
58
+ > holds no responsibility for the security of applications built from this tool.
59
+
60
+ > **New here?** Start with the [Getting Started Guide](GETTING_STARTED.md) — create a new document type and generate your first batch in under 10 minutes.
61
+
62
+ ## Quick Start
63
+
64
+ ```bash
65
+ # Install (creates the venv and installs from uv.lock)
66
+ uv sync
67
+
68
+ # Configure AWS credentials with Bedrock access
69
+ export AWS_PROFILE=your-profile-name
70
+
71
+ # Generate a single FCC invoice
72
+ BYPASS_TOOL_CONSENT=true uv run python -m doc_gen_agent \
73
+ --schema-dir src/doc_gen_agent/schemas/fcc-invoice
74
+
75
+ # Generate a diverse batch of 4 invoices with augmentation
76
+ BYPASS_TOOL_CONSENT=true uv run python scripts/batch_generate.py \
77
+ --schema-dir src/doc_gen_agent/schemas/fcc-invoice \
78
+ --count 4 --workers 2 --augment \
79
+ --extra "FCC broadcast invoices for packaged food companies in the midwest"
80
+ ```
81
+
82
+ ## Architecture
83
+
84
+ ### Single Document Pipeline
85
+
86
+ ```
87
+ data_generator → data_critic → doc_generator → doc_critic → [augmentor → aug_critic]
88
+ ↑ (reject) ↑ (reject)
89
+ └─────────┘ └──────────┘
90
+ ```
91
+
92
+ ### Batch Pipeline (Parallel)
93
+
94
+ ```bash
95
+ uv run python scripts/batch_generate.py --count 10 --workers 3 --extra "your brief here"
96
+ ```
97
+
98
+ 1. **Scenario Generation**: An LLM reads your `--extra` brief + the schema's generation guidance and produces N unique, diverse scenario descriptions
99
+ 2. **Parallel Execution**: Each scenario runs through the full single-doc pipeline in parallel via ThreadPoolExecutor
100
+ 3. **Output**: PDFs, data JSON, augmented versions, and a batch manifest
101
+
102
+ The `--extra` flag is the key to diversity. It accepts a high-level brief that the scenario generator uses to create varied documents:
103
+
104
+ ```bash
105
+ # Generic — less diverse
106
+ --extra "Generate diverse FCC invoices"
107
+
108
+ # Specific — much more diverse
109
+ --extra "FCC broadcast invoices for packaged food companies advertising in the midwest"
110
+ --extra "Local car dealership TV ads across small-market stations in the southeast"
111
+ --extra "Political campaign advertising during election season on major metro stations"
112
+ ```
113
+
114
+ The scenario generator reads the schema's `generation_guidance.md` to understand the document type, then creates scenarios that vary advertisers, agencies, stations, regions, time periods, line item counts, and amounts.
115
+
116
+ ## Agent Descriptions
117
+
118
+ | Agent | Role | Default Model |
119
+ |-------|------|---------------|
120
+ | Scenario Generator | Creates diverse scenarios from brief + guidance | `gpt-oss` |
121
+ | Data Generator | Produces JSON data from schema. Has calculator tool for math verification. | `nova2-lite` |
122
+ | Data Critic | Validates data against schema and domain rules. Has calculator tool. Structured output. | `sonnet` |
123
+ | Doc Generator | Writes HTML/CSS and renders to PDF via WeasyPrint. Has editor for targeted fixes. | `gpt-oss` |
124
+ | Doc Critic | Vision model evaluates PDF quality — layout, typography, truncation, math. Free-text output. | `sonnet` |
125
+ | Augmentor | Picks augraphy augmentation config and applies document aging effects. | `gpt-oss` |
126
+ | Aug Critic | Evaluates augmented doc for legibility and realism. Structured output. | `sonnet` |
127
+
128
+ ## Setup
129
+
130
+ This project uses [uv](https://docs.astral.sh/uv/) and ships a committed
131
+ `uv.lock` for reproducible installs. uv is the recommended workflow.
132
+
133
+ ```bash
134
+ # Install uv (see https://docs.astral.sh/uv/getting-started/installation/)
135
+ curl -LsSf https://astral.sh/uv/install.sh | sh
136
+
137
+ # Create the virtual environment and install all dependencies from uv.lock,
138
+ # including the dev group (pytest, ruff, docs). Requires Python 3.12+.
139
+ uv sync
140
+
141
+ # Run any command inside the managed environment with `uv run`, e.g.
142
+ uv run python -m doc_gen_agent --help
143
+ ```
144
+
145
+ `uv sync` installs the `dev` dependency group by default (configured via
146
+ `[tool.uv] default-groups`). Use `uv sync --no-dev` for a runtime-only install.
147
+
148
+ <details>
149
+ <summary>Alternative: pip or conda</summary>
150
+
151
+ ```bash
152
+ # pip (add the [dev] extra for pytest/ruff/docs tooling)
153
+ pip install -e ".[dev]"
154
+
155
+ # or conda for the environment, then pip for the package
156
+ conda create -n seed python=3.12 -y
157
+ conda activate seed
158
+ pip install -e ".[dev]"
159
+ ```
160
+
161
+ Note: pip resolves dependencies fresh and does not use `uv.lock`.
162
+ </details>
163
+
164
+ WeasyPrint (default renderer) requires system libraries:
165
+ ```bash
166
+ # macOS
167
+ brew install pango gdk-pixbuf libffi
168
+
169
+ # Ubuntu/Debian
170
+ apt-get install libpango-1.0-0 libgdk-pixbuf2.0-0
171
+ ```
172
+
173
+ Configure AWS credentials with Bedrock access:
174
+ ```bash
175
+ export AWS_PROFILE=your-profile-name
176
+ ```
177
+
178
+ ### Packet Pipeline (Multi-Document)
179
+
180
+ ```bash
181
+ BYPASS_TOOL_CONSENT=true uv run python scripts/packet_generate.py \
182
+ --packet src/doc_gen_agent/packets/lending-package \
183
+ --count 3 --workers 2 --augment \
184
+ --extra "First-time homebuyers in the Pacific Northwest applying for a 30-year fixed mortgage"
185
+ ```
186
+
187
+ A packet is a set of different document types that share context — like a loan
188
+ application containing a credit report, pay stubs, and a statement of intent, all
189
+ for the same applicant. The pipeline:
190
+
191
+ 1. **Shared Context Resolution**: An LLM reads all schemas in the packet and generates
192
+ consistent shared values (names, addresses, dates). If the packet config defines
193
+ explicit `shared_context` fields, those are used directly; otherwise the agent infers
194
+ them from the schemas.
195
+ 2. **Sub-Document Generation**: Each document type runs through the full single-doc
196
+ pipeline with shared context injected as extra instructions.
197
+ 3. **PDF Merging**: Individual PDFs are merged into a single multi-document PDF per packet.
198
+ 4. **Label Emission**: Per-section `result.json` files with `document_class`,
199
+ `page_indices`, and `inference_result` (KIE ground truth labels).
200
+
201
+ Output follows the evaluation dataset format for document splitting / classification:
202
+
203
+ ```
204
+ output/packet_<name>_<timestamp>/
205
+ ├── classes.yaml # Document type list
206
+ ├── input/
207
+ │ ├── packet_001.pdf # Merged multi-doc PDF
208
+ │ └── packet_002.pdf
209
+ ├── baseline/
210
+ │ ├── packet_001.pdf/
211
+ │ │ └── sections/
212
+ │ │ ├── 1/result.json # Sub-doc 1 labels
213
+ │ │ └── 2/result.json # Sub-doc 2 labels
214
+ │ └── packet_002.pdf/
215
+ ├── config/
216
+ │ ├── packet.json # Copy of packet config
217
+ │ └── packet_manifest.json # Full run metadata
218
+ └── artifacts/ # Intermediate files (individual PDFs, data JSONs)
219
+ ├── packet_001/
220
+ └── packet_002/
221
+ ```
222
+
223
+ See [docs/packets.md](docs/packets.md) for the full guide — configuration, label format,
224
+ architecture, and design decisions.
225
+
226
+ See [Packet Configuration](#packet-configuration) for how to define packet types.
227
+
228
+ ## Usage
229
+
230
+ ### Single document
231
+
232
+ ```bash
233
+ BYPASS_TOOL_CONSENT=true uv run python -m doc_gen_agent \
234
+ --schema-dir src/doc_gen_agent/schemas/fcc-invoice \
235
+ --extra "Local TV station in Portland, Oregon"
236
+ ```
237
+
238
+ ### Single document with augmentation
239
+
240
+ ```bash
241
+ BYPASS_TOOL_CONSENT=true uv run python -m doc_gen_agent \
242
+ --schema-dir src/doc_gen_agent/schemas/fcc-invoice \
243
+ --extra "Local TV station in Portland, Oregon" \
244
+ --augment
245
+ ```
246
+
247
+ ### Parallel batch generation (recommended)
248
+
249
+ ```bash
250
+ BYPASS_TOOL_CONSENT=true uv run python scripts/batch_generate.py \
251
+ --schema-dir src/doc_gen_agent/schemas/fcc-invoice \
252
+ --count 10 --workers 3 \
253
+ --extra "CPG brands on local TV stations in the American southwest" \
254
+ --augment \
255
+ --batch-name southwest_cpg
256
+ ```
257
+
258
+ ### CLI Options
259
+
260
+ Common flags (work for `__main__`, `batch_generate.py`, and `packet_generate.py` unless noted):
261
+
262
+ | Flag | Default | Description |
263
+ |------|---------|-------------|
264
+ | `--schema-dir` | required | Directory with `schema.json` + optional `*.md` steering docs |
265
+ | `--output` | `./output` | Output root directory |
266
+ | `--extra` | | Diversity brief — describes the theme/scenario for generation |
267
+ | `--data-model` | `nova2-lite` | Model for data generation |
268
+ | `--doc-model` | `gpt-oss` | Model for PDF generation |
269
+ | `--critic-model` | `sonnet` | Model for all critics |
270
+ | `--aug-model` | `gpt-oss` | Model for augmentation decisions |
271
+ | `--renderer` | `weasyprint` | PDF engine: `weasyprint` (HTML/CSS) or `reportlab` (Python) |
272
+ | `--augment` | off | Enable augraphy image augmentation |
273
+ | `--preview` | off | Enable visual self-inspection (requires VL model for doc-model) |
274
+ | `--threshold` | `7` | Acceptance score 1-10 (7 recommended, 8 requires edit cycles) |
275
+ | `--max-attempts` | `5` | Max feedback cycles per loop |
276
+ | `--timeout` | `3600` | Safety timeout in seconds |
277
+
278
+ Batch-only flags (`batch_generate.py`):
279
+
280
+ | Flag | Default | Description |
281
+ |------|---------|-------------|
282
+ | `--count` | `5` | Number of documents to generate |
283
+ | `--workers` | `3` | Max parallel workers (don't exceed 4-5 to avoid Bedrock rate limits) |
284
+ | `--batch-name` | timestamp | Name for the batch output directory |
285
+
286
+ Packet-only flags (`packet_generate.py`):
287
+
288
+ | Flag | Default | Description |
289
+ |------|---------|-------------|
290
+ | `--packet` | required | Path to packet config directory |
291
+ | `--count` | `1` | Number of packets to generate |
292
+ | `--workers` | `2` | Parallel packets within the batch |
293
+ | `--doc-workers` | `1` | Parallel sub-documents within each packet |
294
+ | `--shuffle` | off | Randomize sub-document order in merged PDF |
295
+ | `--context-model` | `gpt-oss` | Model for shared context resolution |
296
+
297
+ ### What to expect from a batch
298
+
299
+ - A single document takes roughly 60-100 seconds end-to-end.
300
+ - With `--count 10 --workers 3` expect ~5-7 minutes wall-clock.
301
+ - Don't push `--workers` above 4-5 — you'll hit Bedrock rate limits.
302
+ - Partial failures are normal. If one doc fails, the others still complete and the
303
+ manifest records which succeeded.
304
+ - Use a specific `--extra` brief. Vague briefs produce same-y output.
305
+
306
+ ### Available Models
307
+
308
+ | Key | Model | Best For |
309
+ |-----|-------|----------|
310
+ | `gpt-oss` | GPT-OSS 120B | Doc generation, augmentation (fast tool calling) |
311
+ | `sonnet` | Claude Sonnet 4.6 | Critics (respects scope rules, good at evaluation) |
312
+ | `nova2-lite` | Amazon Nova 2 Lite | Data generation (fast, cheap, works with calculator) |
313
+ | `nemotron-super` | Nemotron Super 120B | Doc generation (slow but high first-pass quality) |
314
+ | `haiku` | Claude Haiku 4.5 | Fast critic (but less reliable at scope enforcement than sonnet) |
315
+
316
+ ## Schema Directories
317
+
318
+ Each document type lives in its own directory:
319
+
320
+ ```
321
+ schemas/fcc-invoice/
322
+ ├── schema.json # JSON Schema — REQUIRED
323
+ ├── generation_guidance.md # Visual style, data ranges, math rules — optional
324
+ └── samples/ # Reference PDFs for the doc critic — optional, local-only
325
+ ├── README.md # What samples are for + handling rules
326
+ └── *.pdf # git-ignored — never committed
327
+ ```
328
+
329
+ ### samples/ (reference documents) — important
330
+
331
+ The optional `samples/` directory holds real example PDFs used **only** by the
332
+ document critic as a **visual style reference** — they are never seen by the
333
+ generation stages and no content from them is reproduced in the output. See
334
+ [critique.py](src/doc_gen_agent/critique.py) and any
335
+ `schemas/<type>/samples/README.md` for the full explanation.
336
+
337
+ **Sample PDFs are local-only and git-ignored.** Do not commit them: real
338
+ documents may contain third-party names or PII you don't have the right to
339
+ redistribute, which can trigger data-distribution policies and block
340
+ open-source release. You are responsible for having the rights to any sample
341
+ you add. Use `--no-critic-samples` to skip samples entirely. The repository
342
+ ships with **no** sample documents.
343
+
344
+ ### generation_guidance.md
345
+
346
+ This is the key file for controlling document quality and diversity. It tells agents:
347
+ - **Visual style**: layout, fonts, density, colors
348
+ - **Data realism**: value ranges, naming conventions, line item counts
349
+ - **Math rules**: arithmetic constraints (e.g., "GrossTotal = sum of LineItemRate")
350
+ - **Common issues to avoid**: known pitfalls for this document type
351
+ - **Generation Choices**: optional fields with `x-probability` and table presentation variations (see below)
352
+
353
+ The scenario generator also reads this file to create diverse scenarios that respect the document type's constraints.
354
+
355
+ ## Generation Choices
356
+
357
+ Document diversity comes from two sources of per-run variation:
358
+
359
+ 1. **Optional fields with `x-probability`** — schema fields marked with an
360
+ `x-probability` annotation are independently included or omitted per document
361
+ based on their probability.
362
+ 2. **Table presentation variations** — sections that can render either as tables
363
+ or inline fields, declared in `generation_guidance.md` with ~50/50 probabilities.
364
+
365
+ See [docs/generation_choices.md](docs/generation_choices.md) for the full guide:
366
+ conventions, examples for nested and array fields, and how to add it to a new
367
+ document type.
368
+
369
+ ## Output Structure
370
+
371
+ ```
372
+ output/<batch-name>/
373
+ ├── pdfs/ # Clean PDFs
374
+ ├── data/ # Source data JSON per document
375
+ ├── generation_scripts/ # HTML files used to render PDFs
376
+ ├── augmented/ # Augmented PDFs (when --augment)
377
+ ├── config/ # Copy of schema + guidance for reproducibility
378
+ │ └── batch_manifest.json # Full run metadata, scenarios, timing
379
+ ```
380
+
381
+ ## Tests
382
+
383
+ ```bash
384
+ # Run the full unit-test suite (no LLM calls). Integration tests are excluded
385
+ # by default (see addopts in pyproject.toml).
386
+ uv run pytest
387
+
388
+ # Or run a single module
389
+ uv run pytest tests/test_unit.py -v
390
+
391
+ # Integration: isolated doc loop test (requires AWS credentials). Lives under
392
+ # tests/integration/ and is skipped by the default pytest run above.
393
+ BYPASS_TOOL_CONSENT=true uv run python tests/integration/test_doc_gen.py \
394
+ --schema fcc-invoice --model gpt-oss --threshold 7
395
+ ```
396
+
397
+ ## Packet Configuration
398
+
399
+ Packet configs live in `src/doc_gen_agent/packets/<packet-name>/packet.json`.
400
+ See [docs/packets.md](docs/packets.md) for the full guide including config fields,
401
+ shared context modes, label format, and architecture.
402
+
403
+ ### Packet config example
404
+
405
+ ```json
406
+ {
407
+ "name": "insurance-claim-packet",
408
+ "description": "Property insurance claim submission packet.",
409
+ "documents": [
410
+ {
411
+ "document_class": "Insurance Claim",
412
+ "schema_dir": "insurance-claim",
413
+ "required": true,
414
+ "min_instances": 1,
415
+ "max_instances": 1
416
+ },
417
+ {
418
+ "document_class": "Invoice",
419
+ "schema_dir": "invoice",
420
+ "required": true,
421
+ "min_instances": 1,
422
+ "max_instances": 3
423
+ }
424
+ ],
425
+ "shared_context": {
426
+ "claimant_name": "Full legal name of the person filing the claim",
427
+ "claimant_address": "Street address of the claimant"
428
+ },
429
+ "shared_context_hint": "All documents relate to the same insurance claim."
430
+ }
431
+ ```
432
+
433
+ See the CLI Options section above for packet-specific flags.
434
+
435
+ ## Security
436
+
437
+ doc-gen-agent runs AI agents that **write and execute code** and **read/write
438
+ files** on the host in order to render documents. Read this section before
439
+ running it on anything you don't fully trust. See also the disclaimer at the top
440
+ of this README — you are responsible for the security of anything you build with
441
+ this tool.
442
+
443
+ ### Data provenance
444
+
445
+ | Aspect | Detail |
446
+ |--------|--------|
447
+ | Real data in generation? | **No.** The generation stages produce entirely fictional content — all names, addresses, and financial figures are invented. |
448
+ | PII in output? | **No.** Output documents and ground-truth JSON contain no real personal or customer data. |
449
+ | Document templates? | **No.** Each PDF is rendered from freshly generated HTML/CSS (or ReportLab) code; no templates or real documents are copied. |
450
+ | Reference samples? | **Optional, local-only.** Real PDFs in a schema's `samples/` directory are sent **only** to the quality-review critic as a visual style reference. The generation stages never see them and no content from them is reproduced in output. They are git-ignored — see [Schema Directories](#schema-directories). You are responsible for having the rights to any sample you provide. |
451
+ | Reproducibility | Batch/packet runs write a manifest recording the command, model versions, git hash, and config. |
452
+
453
+ ### Code & file execution (most important)
454
+
455
+ The document-generation agent uses tools that act on the host with the
456
+ privileges of the user running the CLI:
457
+
458
+ - **Code execution** — with the `reportlab` renderer the agent runs Python via a
459
+ `shell` tool; with the default `weasyprint` renderer it renders agent-authored
460
+ HTML. Treat all agent-generated code in `output/generation_scripts/` as
461
+ **untrusted model output** — do not blindly re-run it later.
462
+ - **Filesystem access** — file read/write tools operate on model-supplied paths
463
+ with no built-in sandbox or path allowlist.
464
+ - **Tool consent** — the documented run commands set `BYPASS_TOOL_CONSENT=true`,
465
+ which disables the per-tool human-approval prompt. Leave it **unset** when
466
+ running on untrusted input so you can approve tool calls.
467
+
468
+ **Recommendation:** run the pipeline in an isolated environment (container or VM)
469
+ with no sensitive data on disk, restricted network egress, and dedicated,
470
+ least-privilege AWS credentials — not your personal developer profile.
471
+
472
+ ### Untrusted schemas, guidance, and briefs
473
+
474
+ `schema.json`, `generation_guidance.md`, sample PDFs, and the `--extra` brief are
475
+ all injected into agent prompts. Treat content from untrusted sources as a
476
+ **prompt-injection** vector: a malicious schema or guidance file could attempt to
477
+ steer an agent into misusing the code/file tools. Only run schemas you trust, or
478
+ run inside the isolated environment described above.
479
+
480
+ ### AWS credentials
481
+
482
+ Model calls go to Amazon Bedrock using the credentials resolved from your
483
+ `AWS_PROFILE` (see [session.py](src/doc_gen_agent/session.py)). Any code the agent
484
+ executes inherits that environment, so those credentials — and whatever they can
485
+ access — are reachable by agent-run code. Use a scoped, Bedrock-only profile and
486
+ avoid broad/admin credentials.
487
+
488
+ ### Cost
489
+
490
+ Generation runs make repeated Bedrock calls and use critic-driven retry loops.
491
+ Large batch counts or high `--max-attempts` increase token spend. Keep
492
+ `--max-attempts`/`--timeout` conservative and monitor Bedrock usage.