Document Readers

Three DocumentReader backends read a page into one DocumentPage: blocks with their regions in source pixels, text, confidence, words and table cells, the reading order, and optionally Markdown. A tool, a graph node or a route that calls VisionRuntime::read works the same whichever backend answers (spec 3.7 scenario S8).

BackendFeatureRunsAnswers inGives
PpOcrReaderocrOn the device: PP-OCRv6 through oar-ocr on ONNX RuntimeSentPixelsOne block per text line, its quad, recognition confidence and words
PaddleOcrVlReaderocr-vl (ocr-vl-metal for Apple GPUs)On the device: PaddleOCR-VL-1.6 and PP-DocLayoutV3 through oar-ocr-vl on CandleSentPixelsLayout blocks (titles, text, tables, formulas, figures, seals) in the layout model's reading order, tables as rows, Markdown
NimDocumentReadernimRemote: NVIDIA's CV endpointsNormalized { scale: 1, order: Xy }Layout blocks from page elements, lines from OCR words, table cells from table structure, chart labels from chart elements

The local readers implement the trait for SentImage; NimDocumentReader implements it for ReleasedImage only, so a page reaches NVIDIA only through the egress gate.

The Page

DocumentPage is published as a JSON Schema in adk-vision/schema/document-page.json; its regions are RegionSet regions, each naming the backend, its coordinate frame and the transform chain.

FieldWhat it holds
blocks[].kindtext, title, table, formula, figure, seal, checkbox or handwriting
blocks[].regionThe block's box or polygon in source pixels; label is the backend's class (paragraph, doc_title, chart, ...)
blocks[].textLines separated by newlines; a table's rows with cells separated by tabs
blocks[].confidenceThe lowest recognition confidence in the block, else the layout confidence; escalation triggers read it
blocks[].wordsRecognised words with their regions; a chart's words carry their role (xlabel, ylabel, ...) as the label
blocks[].cellsTable cells with row, column, spans and text, when the backend measures them
readingOrderIndexes into blocks, in reading order
markdownThe page as Markdown, when ReadOptions::markdown is set

Granularity differs by backend; the shape does not:

BackendBlocksWordsCells
PP-OCRv6One per lineCharacter boxes merged at spaces—
PaddleOCR-VL-1.6Layout blocks—— (tables come as rows in text and in Markdown; the model gives no cell geometry)
NVIDIA NIMLayout blocks, and one per line outside themOCR wordsFrom the table-structure model

PP-OCRv6

[dependencies]
adk-vision = { version = "3.0.0", features = ["ocr", "fetch"] }
use std::sync::Arc;
use adk_vision::{
    DecodeLimits, FetchConfig, InMemoryAcceptanceStore, ModelFetcher, PpOcrReader, PpOcrV6Size,
    ReadOptions, SourceImage, VisionCx, VisionRuntime,
};

let fetcher = ModelFetcher::new(FetchConfig::from_env(), Arc::new(InMemoryAcceptanceStore::new()));
let reader = PpOcrReader::fetch(&fetcher, PpOcrV6Size::Small).await?;
let runtime = VisionRuntime::builder().reader(Arc::new(reader)).build()?;

let page = SourceImage::decode(&std::fs::read("invoice.png")?, &DecodeLimits::default())?;
let read = runtime.read(&VisionCx::new(), &page, &ReadOptions::default()).await?;
for &i in &read.value.reading_order {
    println!("{}", read.value.blocks[i].text);
}

The models are PaddlePaddle's own ONNX exports on Hugging Face, byte-identical to the files oar-ocr's ModelScope registry lists. oar-ocr's auto-download stays off: the fetcher downloads by revision into the Hugging Face cache, checks every file's SHA-256, and the reader hashes the ONNX bytes again as it loads them. The recognition dictionary is read from the inference.yml pinned beside the model.

ManifestRepositoryFilesSize
pp-ocrv6-tiny-det, -recPaddlePaddle/PP-OCRv6_tiny_{det,rec}_onnxinference.onnx (+ inference.yml for rec)1.8 MB + 4.5 MB
pp-ocrv6-small-det, -recPaddlePaddle/PP-OCRv6_small_{det,rec}_onnxthe same9.9 MB + 21.2 MB
pp-ocrv6-medium-det, -recPaddlePaddle/PP-OCRv6_medium_{det,rec}_onnxthe same62.0 MB + 76.6 MB

PaddleOCR-VL-1.6

[dependencies]
adk-vision = { version = "3.0.0", features = ["ocr-vl", "fetch"] }
use adk_vision::{PaddleOcrVlReader, VlDevice};

let reader = PaddleOcrVlReader::fetch(&fetcher, VlDevice::Cpu).await?;

PP-DocLayoutV3 finds the blocks and their order; PaddleOCR-VL-1.6 reads each block's crop as text, a table, a formula or a chart. Generation runs on a blocking thread, one page at a time per reader. The loader refuses a model directory that holds a *.safetensors file the manifest does not pin, because Candle would load every one it finds.

ManifestRepositorySize
paddleocr-vl-1.6PaddlePaddle/PaddleOCR-VL-1.61.93 GB
pp-doclayoutv3PaddlePaddle/PP-DocLayoutV3_safetensors133 MB

NVIDIA NIM

[dependencies]
adk-vision = { version = "3.0.0", features = ["nim", "ocr", "guardrail", "fetch"] }

The page leaves only through the egress gate; here local PP-OCRv6 finds the personal text (PersonalTextRedactor, feature guardrail) and the gate fills it before release:

use std::sync::Arc;
use adk_core::egress::EgressPolicy;
use adk_vision::{
    CallOptions, EgressAction, EgressConfig, EgressGate, InMemoryEgressRecorder, NimCvConfig,
    NimDocumentReader, PersonalTextRedactor, PpOcrReader, PpOcrV6Size, RedactionClass,
    VisionRuntime,
};

let ocr = PpOcrReader::fetch(&fetcher, PpOcrV6Size::Tiny).await?;
let personal_text = PersonalTextRedactor::new(Arc::new(ocr))
    .with_labelled_fields(["Name", "Address", "Email", "Phone"]);
let reader = NimDocumentReader::new(
    NimCvConfig::new("https://ai.api.nvidia.com/v1/cv").with_api_key_from_env(),
)?;
let gate = EgressGate::new(
    EgressPolicy::allow_private_networks(),
    EgressConfig::default()
        .redacting(RedactionClass::personal_text())
        .with_rule("ai.api.nvidia.com", &["document_page"], EgressAction::Allow),
    Arc::new(InMemoryEgressRecorder::new()),
)
.with_redactor(Arc::new(personal_text));
let runtime = VisionRuntime::builder().remote_reader(Arc::new(reader)).egress_gate(gate).build()?;
let read = runtime
    .read_with(&cx, &page, &ReadOptions::default(), &CallOptions::new().with_data_class("document_page"))
    .await?;
StepModelRequests per page
Textnvidia/nemotron-ocr-v1 (words), nvidia/nemoretriever-ocr, or baidu/paddleocr (lines)1
Blocksnvidia/nemotron-page-elements-v3; elements under confidence 0.3 are ignored1
Table cellsnvidia/nemotron-table-structure-v1 on each table's crop1 per table
Chart labelsnvidia/nemotron-graphic-elements-v1 on each chart's crop1 per chart
  • Configuration. Nothing ships a default URL: name the hosted base URL or a self-hosted NIM, and with_model_url for a NIM that serves one model at its own URL. The descriptor's hosts are those of every URL the reader calls, so the egress policy decides each one.
  • Transport. Images go inline as PNG data URIs (NVIDIA's asset upload API is retired), up to 8 MiB by default. Table and chart crops are cut from the released pixels, so nothing outside the released image leaves. The client timeout is 180 s, above the gateway's 120 s; a client-side limit allows 40 requests per minute.
  • Cost. NVIDIA publishes no per-call price, so the descriptor carries none: each read records one image and one page at zero cost under the host, and unit caps bound it.
  • Terms. The hosted endpoints run under NVIDIA's API Trial terms and suit prototypes. A self-hosted NIM is free for development and research; serving end users needs NVIDIA AI Enterprise.
StatusMeaningAdkError
404 text/plainNo such routeNotFound vision.nim.no_route, naming the URL
404 problemThe key is not entitled to the modelForbidden vision.nim.not_entitled; the caller's account id is not repeated
410The endpoint is retiredNotFound vision.nim.retired, with the date
422The body was refusedInvalidInput
400The input was refusedUnsupported
429Rate limitedRateLimited, with Retry-After
500, 502, 503Worker error, retried onceUnavailable
504The gateway's 120 s timeoutTimeout

Measured

On the generated report page (adk-vision/tests/fixtures/documents/, 1000×1300, ground truth from the drawing script), through VisionRuntime::read on an Apple Silicon laptop, CPU, debug build with dependencies at opt-level = 1. Character accuracy is over the page's words; edge error is the largest edge distance between each ground-truth line's ink box and the backend's line box.

BackendReadCharacter accuracyLines foundEdge error median / max
PP-OCRv6 tiny0.1 s100.0%27/277 px / 11 px
PP-OCRv6 small0.4 s100.0%27/277 px / 9 px
NVIDIA NIM (hosted)2.0 s99.6%27/271.3 px / 2.1 px
PaddleOCR-VL-1.6, CPU135.6 s100.0% without chart labels, 92.5% with4/27 (blocks, not lines)5 px / 44 px
PaddleOCR-VL-1.6, Metal12.4 sthe samethe samethe same

PP-OCRv6's line boxes include the detector's unclip margin, about 5–7 px around the ink. PaddleOCR-VL answers in layout blocks, so only single-line blocks match a ground-truth line, and it reads a chart as a figure: its tick and axis labels need chart recognition, which the reader does not run.

Verifying

SuiteCommand
Contract tests on NIM's recorded answers, and its conformance runcargo test -p adk-vision --features nim,conformance --test nim_contract_tests
The page shape across the three backends (S8)cargo test -p adk-vision --test s8_document_schema_tests
PP-OCRv6 live, with its conformance runcargo test -p adk-vision --features ocr,fetch,conformance --test ocr_live_tests -- --ignored
PaddleOCR-VL-1.6 live, with its conformance runcargo test -p adk-vision --features ocr-vl,fetch,conformance --test ocr_vl_live_tests -- --ignored
NIM live through the egress gate, with redactioncargo test -p adk-vision --features nim,ocr,guardrail,fetch,conformance --test nim_live_tests -- --ignored