Run the Nemotron OCR Pipeline
Run tutorials/synthetic/omni/ocr_pipeline.py over a Hugging Face dataset. Start with local OCR, inspect the boxes, and then enable remote verification and QA conversation generation.
1. Start the GPU container
From the repository root:
Inside the container:
For private or gated data, authenticate through the environment or Hugging Face CLI. Do not commit tokens.
2. Run a small OCR-only sample
The runner starts Ray, uses Xenna, writes ocr_worker<worker-id>.jsonl shards, and merges them to the requested file after success.
--output-path is a base file path, despite the current help text describing it as a directory. Include a .jsonl filename. Without a suffix, the writer creates <name>_worker*.jsonl and merges them to <name>.jsonl beside the supplied path.
Inspect one record:
3. Enable scoring and QA
Create an NVIDIA API key at NVIDIA Build, then export it without putting the value in shell history:
Each image causes one remote verifier request, so validate a small sample first:
Add --scoring-qa-fail-on-missing-text to invalidate images with uncovered text. Otherwise missing regions are recorded, dense dump is disabled for that image, and QA uses boxes that passed scoring. Add --valid-only to exclude invalid images; without it, failed records remain with an error string.
CLI reference
OCR merge_level, verifier generation/batch settings, priority mode, and API client concurrency are Python-only settings.
4. Use the Python API
The CLI merges shards only after a successful pipeline run. This example uses an outer finally so workers stop before any available shards are merged, including after a pipeline failure.
Configure stages individually when you need Python-only options:
JsonlSampleWriterStage defaults valid_only=True when constructed directly, while the tutorial CLI defaults --valid-only to false and passes that value explicitly. Set valid_only=False to retain invalid records for inspection or a later rerun.
5. Read scored output
Output also retains ocr_scoring_prompt and ocr_scoring_response_raw. These can be large with the 16,384-token response budget; remove them downstream if training does not require provenance.
Batching and failures
- OCR has
batch_size=32; image errors are caught individually. - Scoring QA has
batch_size=16; each worker permits 10 concurrent requests. - Invalid inputs skip later model stages but reach the writer unless
--valid-onlyis set. - No OCR boxes skips scoring without invalidating the record.
- Empty/unparseable verifier output, no boxes passing thresholds, and optionally missing text invalidate the image.
- Conversation choices are deterministic for framework task identity. Do not set
task_idyourself. - Weights download once per node and load once per OCR worker.
Rerun safely
Image extraction is idempotent by filename, but inference is not resumable:
- Use a new output basename or remove stale
<stem>_worker*.jsonlshards. - Preserve invalid rows initially so
image_idanderrorcan drive a targeted retry dataset. - Do not treat cached JPEGs as completed OCR; reruns process every selected unique ID.
- After interruption, inspect worker shards before merging or discarding them.
- After success, verify record count, errors, bbox thresholds, missing-text rate, and conversation mix.