Add Word document generation Colab notebook (uses the docx processor plugin) - #884
Add Word document generation Colab notebook (uses the docx processor plugin)#884mvansegbroeck wants to merge 2 commits into
Conversation
Adds docs/colab_notebooks/8-generating-word-documents.ipynb, a standalone notebook showing how to turn generated rows into real .docx files: one Pydantic model serving as both the LLM output_format and the renderer's input contract, sampler controls that label the corpus by construction, and python-docx rendering of headings, tables, footers, and Word core properties. Follows the 7-nemotron-personas pattern: a self-contained Colab notebook with an Open in Colab badge and the standard install/API-key setup cells, rather than a numbered entry in the docs/notebook_source tutorial series. It is referenced from an upcoming dev note. Because it is not part of docs/notebook_source, it is not executed by make test-run-tutorials and adds no dependency to the notebooks group; python-docx is installed by the notebook's own Colab setup cell. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: mvansegbroeck <mvansegbroeck@gmail.com>
|
Fern preview: https://nvidia-preview-pr-884.docs.buildwithfern.com/nemo/datadesigner
|
Greptile SummaryThis PR adds a standalone Colab notebook demonstrating generation of structured Word documents through the
|
| Filename | Overview |
|---|---|
| docs/colab_notebooks/8-generating-word-documents.ipynb | Adds the complete Colab workflow for configuring, generating, rendering, and inspecting synthetic Word documents. |
Reviews (2): Last reviewed commit: "docs: use the docx processor plugin in t..." | Re-trigger Greptile
| "import getpass\n", | ||
| "import os\n", | ||
| "\n", | ||
| "from google.colab import userdata\n", |
There was a problem hiding this comment.
Colab import breaks local execution
When this notebook is run in a local Jupyter environment, the unguarded google.colab import raises ModuleNotFoundError before the API-key fallback runs, preventing the advertised local execution path from reaching generation.
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/colab_notebooks/8-generating-word-documents.ipynb
Line: 79
Comment:
**Colab import breaks local execution**
When this notebook is run in a local Jupyter environment, the unguarded `google.colab` import raises `ModuleNotFoundError` before the API-key fallback runs, preventing the advertised local execution path from reaching generation.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Replaces the self-contained renderer with the data-designer-docx plugin, so the notebook demonstrates the production shape rather than an inline loop over the finished dataframe. The notebook now installs the plugin, verifies Data Designer discovered it through its entry point, and adds a single DocxProcessorConfig processor. The WordDocument schema is imported from the plugin instead of being redefined, since the schema is the contract between the LLM and the renderer and the two halves belong in the same package. Rendering happens inside the pipeline: files stream out per batch, and the document path is written back into the dataset automatically. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: mvansegbroeck <mvansegbroeck@gmail.com>
|
Updated in 35f580e — the notebook now uses the The first revision was the self-contained version: it defined What changed
It also gained a plugin-discovery check, which is the thing people actually get stuck on: from data_designer.plugins.plugin import PluginType
from data_designer.plugins.registry import PluginRegistry
print("processor plugins:", PluginRegistry().get_plugin_names(PluginType.PROCESSOR))
# -> processor plugins: ['docx']Net effect: 32 cells down to 22, and rendering now happens inside the pipeline — files stream out per batch and
|
What
Adds
docs/colab_notebooks/8-generating-word-documents.ipynb— a standalone Colabnotebook that turns generated rows into real
.docxfiles: headings, a front-mattermetadata table, numbered sections with bullets, a key-data table, page footer, and Word
core properties.
Single file. No
docs/notebook_source/counterpart.Why
Data Designer produces rows; document pipelines consume
.docx. Teams buildingenterprise RAG ingestion, document classifiers, or DLP tooling need document corpora
they are structurally not allowed to obtain — the real policy library lives in a
customer's SharePoint.
Generating them keeps the ground truth attached: the sampler controls that produced each
document are already columns in the dataset, so the corpus is labelled by construction
rather than by an annotation pass.
This notebook will be referenced from an upcoming dev note.
Usage
Open the badge at the top of the notebook, or run locally. The pipeline is:
The load-bearing idea is that one Pydantic model does two jobs — it is the
output_formatof the LLM column and the input contract of the renderer:Because both ends share one definition, "the model produced something the renderer can't
handle" becomes a Pydantic validation error on the column — which Data Designer already
retries — instead of a parsing failure downstream. There is no markdown parsing anywhere
in the notebook.
How
Placement. Follows the
7-nemotron-personas.ipynbpattern: a self-contained Colabnotebook with the Open in Colab badge and the standard install /
NVIDIA_API_KEYsetupcells (marked
nemo_colab_inject, matchinggenerate_colab_notebooks.py), rather than anumbered entry in the
docs/notebook_sourcetutorial series.Two consequences, both intentional:
make test-run-tutorials, which globsdocs/notebook_source/*.py.A full document at
max_tokens=8192per record is not something to run on every CI pass.notebooksgroup.python-docxis installed by thenotebook's own Colab setup cell, the same way notebook 4 handles
pillowanddatasets.Numbering.
8-rather than7-, since7-nemotron-personas.ipynbalready occupiesthat slot in
colab_notebooks/.Content notes. The notebook covers two things worth calling out explicitly, because
both are easy to get wrong:
Field(description=...)strings are prompt text, not documentation — Data Designerserializes the JSON Schema into the prompt inside
<response_schema>tags.of the JSON, not the arithmetic inside it, so a model asked for three columns
occasionally returns a row with two cells. Padding is cheaper than a retry.
It closes by pointing at
data-designer-docxfor the production shape, where rendering moves inside the pipeline as a processor.
Validation
The notebook body was executed end to end against a stub OpenAI-compatible model server
(Colab-injected cells stripped, as a local run would): 4 documents written — 1 from
preview(), 3 fromcreate()— and read back through python-docx to confirm headings,tables, footer, and core properties.
It has not been run against a live model in this branch; the generation path is identical
to the plugin's, which is covered by tests in the Plugins repo.
git statuson this branch shows exactly one added file.🤖 Generated with Claude Code