Prepare Fine-Tuning Data with Docling and SDG Hub
Open Data Hub treats document conversion and synthetic data as two steps in the same model-customization path:
- Docling turns PDFs, Office files, HTML, and similar sources into structured Markdown or JSON.
- SDG Hub runs a YAML flow of composable blocks against those documents and writes synthetic Q&A or chat turns.
- You fine-tune on the resulting JSONL with Training Hub or a Workbench VolcanoJob.
This guide runs both libraries inside an Alauda AI Workbench. Neither package is preinstalled on the built-in images. For thousands of PDFs, do not grow the workbench — use the Ray Data / Kubeflow Pipelines paths at the end.
A runnable notebook that follows the same steps lives next to this page:
Keep the notebook and assets/docling-sdg/ together when you download them:
TOC
PrerequisitesInstall in the WorkbenchConvert documents with DoclingGenerate synthetic data with SDG HubWrite a fine-tuning JSONLScale beyond one workbenchTroubleshootingNext stepsPrerequisites
Built-in Workbench images do not ship Docling, SDG Hub, tesseract, or qpdf.
Scanned PDFs that need OCR therefore require extra system libraries or a
custom workbench image.
Install in the Workbench
Open a JupyterLab terminal in the workbench. Pin the packages in a virtual environment on the workspace PVC so a pod restart does not wipe them.
Register the venv as a Jupyter kernel so notebook cells use it:
In JupyterLab, switch the notebook kernel to Python (Docling + SDG).
Air-gapped clusters: download wheels on a connected machine, upload them with the JupyterLab Upload Files button, and install as in Install a Python Wheel File Offline. Docling also downloads layout and table models on first convert. Prefetch them and point the cache at the PVC:
docling 2.70 and later need Python 3.10+. Standard Data Science is 3.12, which
is fine. Do not install into the Minimal Python image unless you add the rest of
the data-science stack yourself.
Convert documents with Docling
Docling is the Python library Open Data Hub uses to prepare unstructured data
for model consumption. The in-workbench path is a DocumentConverter over files
on the PVC. That is enough for a few dozen native-digital PDFs. CPU cost is
typically 5–60 seconds per file.
The CLI is equivalent for a one-off file:
Use Markdown (or plain text) as the SDG document column. Keep the JSON when
you need tables, bounding boxes, or a later RAG index — AutoRAG's
text-extraction stage writes the same DoclingDocument JSON. See
Optimize a RAG Application with AutoRAG Pipelines.
ODH's notebooks under
opendatahub-io/data-processing
cover convert, chunk, field extraction, and subset selection. Clone that
repository in JupyterLab if you need those recipes; this page only converts far
enough to feed SDG Hub and then SFT.
Generate synthetic data with SDG Hub
SDG Hub is a
block-and-flow library. A block does one thing (build a prompt, call an LLM,
parse the reply). A flow is a YAML list of blocks. Open Data Hub clones
sdg_hub/examples
and runs those notebooks from a workbench. The same install works here.
Configure SDG Hub with an OpenAI-compatible teacher. Provide either an in-cluster
InferenceService predictor URL or any other /v1 chat endpoint you control.
SDG_MODEL must match a model name the server lists at /v1/models.
Discover built-in flows, then either load one by id or load a custom YAML. The
knowledge-tuning flow epic-jade-656 (Extractive Summary Knowledge Tuning) is
the ODH default for domain Q&A, but it expects extra in-context columns
(document_outline, icl_document, icl_query_1 …) and a teacher that can
hold concurrency of about 50. Start with a three-block flow instead, then
switch to a registry flow once the teacher and schema are in place.
assets/docling-sdg/flow.yaml
is that three-block flow: prompt → LLMChatBlock → extract. Required columns
are document and domain.
Always dry_run before generate. Knowledge-tuning notebooks on a 266-article
corpus take hours even with a 50-way concurrent teacher; enable_time_estimation
prints a projection so you can size NUMBER_OF_SUMMARIES and concurrency
before you pay for the full run.
For the extractive-summary knowledge-tuning flow, follow
examples/knowledge_tuning
in the SDG Hub repo: parse with Docling, then generate several augmentations
per document (thematic summaries, relationships, atomic facts) and three Q&A
pairs per summary. That is the Open Data Hub path for injecting proprietary
facts into an instruction-tuned model.
Write a fine-tuning JSONL
Training Hub wants one chat object
per line. Map the SDG output columns onto messages:
Pass data_path=str(out_path) to training_hub.sft(...) or
training_hub.osft(...). For LLaMA-Factory, keep the same JSONL and point
dataset at it as in Fine-tuning LLMs using Workbench.
A second JSONL of raw document text ({"text": "..."}) is the CPT corpus if you
want CPT → SFT instead of SFT alone — see
Continued pre-training.
Scale beyond one workbench
The Ray batch path mounts one RWX PVC on every worker, runs each PDF inside a subprocess so a hung converter can be killed, and writes Markdown + JSON back to the same volume. Do not schedule Docling actors on the Ray head.
The KFP SDG path is the Open Data Hub follow-on after the workbench notebooks:
a ConfigMap for the flow YAML, a Secret for the teacher API key, then a
pipeline run. Alauda's mirrored component is
the pipelines-components SDG Hub component (components/data_processing/sdg)
(stability: beta).
Troubleshooting
Next steps
- Fine-tuning LLMs with Training Hub —
sft/osft/lora_sfton the JSONL. - Fine-tuning LLMs using Workbench — LLaMA-Factory VolcanoJob.
- Fine-Tuning with Kubeflow Trainer v2 — cluster
TrainJobwith adataset-initializer. - Optimize a RAG Application with AutoRAG Pipelines — Docling as a pipeline stage rather than a workbench library.
- Upstream: Docling (MIT), SDG Hub (Apache-2.0), Open Data Hub data-processing (Apache-2.0).