Layout labels every region.
PP-DocLayoutV3 scans each page image and returns labelled regions — text, titles, tables, figures, formulas, seals — each with a bounding box in raster pixels.
A visual guide to the document pipeline
Watch a page become labelled regions, recognized content and a reading order you can trust. Then learn to read the JSON it returns.
Three ideas carry the whole pipeline: a page is a map of labelled regions, a model fills each region in, and block_id — not position — decides how to read it.
PP-DocLayoutV3 scans each page image and returns labelled regions — text, titles, tables, figures, formulas, seals — each with a bounding box in raster pixels.
The API crops every labelled region and PaddleOCR-VL on vllm-paddleocr turns it into text, an HTML table, a LaTeX formula or an image reference.
Read blocks in block_id order for every page. A null order is a label choice — captions, headers and tables still have a fixed place in block_id.
The JSON keeps warnings and per-page errors; captions and footnotes link to their objects by block_id adjacency and label. Markdown is a rendering of the same blocks — not a second opinion.
Follow a single page image through layout, recognition and assembly. Each pass shows what the API or the model contributes.
Whether the upload is a PDF, a photo or an Office file converted by LibreOffice, the pipeline sees the same thing: rasterized page images inside hard pixel and page budgets. Office input (.docx .pptx .xlsx, legacy .doc .ppt .xls, OpenDocument .odt .odp .ods) is rendered to PDF by LibreOffice first and reports an office_converted info warning.
Defaults from .env.example. A page over the per-page pixel budget fails closed with 413; pages are processed in blocks of up to 24 pages and 100 M pixels; extra pages are cut with a pages_truncated warning.
PP-DocLayoutV3 scans the page image and returns regions with bounding boxes. At this stage nothing is text — the page is a map of rectangular areas to read.
Illustrative regions. Boxes arrive before any labels or content.
Each region receives a layout tag: text, doc_title, table, figure_title, seal, header and nineteen more. The label already decides whether the block gets an order or appears in Markdown.
Illustrative labels. order is null by label for captions, headers, footers and page numbers.
The API crops each labelled region and sends it to vllm-paddleocr. Content lands back on its block: prose as text, tables as HTML with rowspan/colspan, formulas as LaTeX, images and seals as image references.
Labelled regions dispatched within lane and inflight budgets
Text, HTML tables, LaTeX in $$ … $$, and imgs/img_in_*_box_…jpg references for visual blocks.
Illustrative shapes. Tables keep empty cells empty; formulas stay verbatim.
block_id gives the reading order for every block on the page. Captions sit next to their tables and figures in block_id, and footnote markers point to notes on the same page — the JSON has no relations field, so links come from these reading rules. Every block keeps its bbox — p{page}:b{block_id} addresses any fact back to its region.
Illustrative blocks. A link without evidence is reported as unresolved, not guessed.
Per-page Markdown renders the same blocks for humans: headings, paragraphs, tables, image references. The JSON keeps the full structure — every block, bounding box, warning and page error the Markdown omits.
ocr-api · rendering and delivery{"page":1,"blocks":[{"block_id":1,"type":"doc_title",
"order":1,"bbox":[52,60,398,96],
"content":"Invoice 2026-041"}],
"markdown":"# Invoice 2026-041\n…",
"error":null}Pick a sample page, then toggle the reading order, the caption links and the marginal furniture. The block list is the order the JSON gives you.
block_id, not position. The badges follow block_id. Furniture — header, footer, number, aside_text — is page metadata, not body text.
An authored example,
not an OCR run.
data-block-type; badges show block_id when enabled.block_id orderAurelia Office Supplies · VAT DE-3321
Invoice 2026-041
Billed to Meridian Works, 14 Dock Lane, Bremen
3 rows · 2 items · total 162.50
Table 1 — Line items
Payment due within 14 days.
IBAN DE00 1234 · Page copy
# Invoice 2026-041 Billed to Meridian Works, 14 Dock Lane, Bremen | Item | Qty | Amount | |---|---|---| | Desk lamp | 2 | 118.00 | | Cable set | 5 | 44.50 | Table 1 — Line items Payment due within 14 days.
# Invoice 2026-041 Billed to Meridian Works, 14 Dock Lane, Bremen | Item | Qty | Amount | |---|---|---| | Desk lamp | 2 | 118.00 | | Cable set | 5 | 44.50 | Table 1 — Line items Payment due within 14 days.A paper page with a figure.
## 3.2 Latency on short documents Recognition cost falls sharply once page images stay under the pixel budget.† <img src="imgs/img_in_image_box_60_164_260_274.jpg" alt="Image" /> Figure 2 — Time per page by pixel budget Section 4 extends the measurement to multi-column pages.A form page with a seal.
# Form 943 — Employer’s Return Enter the employer identification number and the tax year before signing. | Field | Value | |---|---| | EIN | __-_______ | | Year | 20__ | <img src="imgs/img_in_seal_box_200_266_296_362.jpg" alt="Image" /> Sign here. A stamped seal may overlap the signature line.
The lab reads authored data embedded in this page. A real run can differ — use it to practise the reading rules, not to predict output.
One row per layout tag. order says whether the block is numbered; markdown says whether the page Markdown contains it. Both are decided by the label, not by position.
| Label | What it is | order | markdown | How to read it |
|---|---|---|---|---|
abstract | Abstract | numbered | yes | Typed section before the body, in papers. |
algorithm | Code or algorithm | numbered | yes | A code block; markdown carries no fences. Pseudocode can instead arrive as display_formula. |
aside_text | Side or margin text | null | no | Page metadata — arXiv identifiers, side navigation. The chunker can keep it in body chunks; set it apart when reading. |
chart | Chart | null | yes | Mention presence, caption and source; never state values. |
content | Table of contents | numbered | yes | Its page numbers are printed labels, not OCR page indexes. |
display_formula | Display formula | numbered | yes | Keep the $$ … $$ LaTeX verbatim. Matrices and pseudocode land here too. |
doc_title | Document title | numbered | yes | The top heading. A second one is often a subtitle or a separate article — confirm from content. |
figure_title | Figure, table or chart caption | null | yes | Usually adjacent in block_id to its object; confirm by label. An isolated trailing caption may be unresolved. |
footer | Page footer | null | no | Copyright, venue, disclaimers, funding. Report repeats once. |
footer_image | Footer image | null | no | A logo. Mention it with the adjacent footer; never describe it. |
footnote | Footnote | null | no | Link its marker to body text on the same page; a note can lack a marker. |
formula_number | Equation number | numbered | no | Usually the display_formula just before it in block_id; after a text block it numbers an equation inside that prose. |
header | Page header | null | no | Running title, date, publication name — page metadata. |
header_image | Header image | null | no | A logo; it can sit outside the top band. Never describe it. |
image | Image | null | yes | Mention presence and caption; never describe. Markdown shows an imgs/img_in_image_box_…jpg reference. |
inline_formula | Inline formula | numbered | yes | Mostly standalone; inside prose, math stays inside text as $ … $. Adjacent fragments can be one split formula — flag it. |
number | Printed page number | null | no | A printed label such as "12" or "C7" — not the page index. |
paragraph_title | Section heading | numbered | yes | Level only from explicit numbering. Also receives "References" and slide titles; bylines are usually text. |
reference | References region | — | — | Dropped by the pipeline before recognition; bibliography arrives as reference_content. |
reference_content | Bibliography entry | numbered | yes | One entry per block, starting "[n]" or "n." — keep the numbering. |
seal | Seal or stamp | numbered | yes | Mention presence only; the stamp text is not read. |
table | Table | null | yes | HTML <table> with rowspan/colspan; empty cells stay empty. Flag tables continued on the next page. |
text | Body text | numbered | yes | The body. An empty block sharing a group_id keeps its text in that group — it still carries an order. |
vertical_text | Vertical text | numbered | yes | CJK vertical columns; block_id ran right to left on the pages observed — flag any inversion. |
vision_footnote | Note under a figure or table | null | yes | Source, photo credit, legend or URL for the object just before it. |
Condensed from references/block-types.md ↗ — the skill file is the owning reference and adds observed variants per tag.
Each pass in the journey belongs to a different part of the stack. Knowing who does what tells you where a surprising output can come from.
Admission budgets, Office conversion, rasterization, dispatch and final assembly all live in the API. Per-page failures become structured page errors instead of a failed request.
warnings[] and pages[i].error first.Region detection and labelling happen inside the OCR API's pipeline, not on the model server. The 25 tags and every bounding box come from this stage.
The vision-language model reads each cropped region and returns text, HTML tables, LaTeX or image references. Recognition needs the GPU; a page that fails VLM recognition surfaces as a page error.
The local PaddleOCR-VL tokenizer already counts each block's content_tokens during /parse and sums them in the top-level usage. When the same JSON is later chunked for RAG, the chunker reuses that tokenizer on CPU — no second GPU inference. Same input and options give byte-identical chunks.
Parse options trade fidelity against time and payload size. They are per-request choices — the template defaults suit most first reads. Two more shape the payload: output (markdown, json or both, default both) chooses which of markdown and blocks each page carries, and json_rag=true adds a separate top-level json_rag export, null unless requested or when json_rag_failed is reported.
max_pages caps how many pages are parsed — a truncated result sets pages_truncated, so say the document is partial; a value above OCR_MAX_PAGES is rejected with 422. dpi (50–400) sets raster density for PDF and Office pages: higher reads small print better and costs more time per page, inside the 25M per-page pixel cap. On image input it is ignored with a dpi_ignored warning.
Tables can render as html (the API default, with rowspan/colspan spans) or markdown; the console preselects markdown · pipes. HTML keeps merged cells exact; markdown tables are easier to quote but lose span structure.
Off by default in the API; the console's include figures box starts checked. When enabled, each page carries base64 PNG crops in images with matching image_names; a crop over OCR_MAX_EMBEDDED_IMAGE_BYTES is skipped with an images_truncated warning. When off, visual blocks still appear as imgs/img_in_*_box_… references in Markdown and as typed blocks in JSON.
Parse a small document in the console, then compare the block list with this page's lab. The launcher prints the console URL:
pwsh .\stack.ps1 urls
bash stack.sh urls
Terms this page uses, and the owning documents that define the exact behavior.
The per-page index of a block and its reading order. Read blocks[] in block_id order; never re-sort by bounding box. p{page}:b{block_id} is the provenance address of any fact.
order is null by label — table, figure_title, image, chart, vision_footnote, footnote, header, footer, number, aside_text, header_image and footer_image never get one. Null means "this label is not numbered", not "unplaced": the block still has its block_id position.
A block's bounding box in raster pixels, origin top-left: [x0, y0, x1, y1]. Use it to point back at the page or to crop a region for a focused /ocr task — not to reconstruct reading order.
A link between blocks — a caption to its table or figure, a footnote marker to its note. The /parse JSON has no relations field: resolve links from block_id adjacency and labels, as the smart-document-reader skill describes. The RAG chunker records them as relations on chunks, with status unresolved when evidence is missing — never invented.
A rendering of the same blocks: headings, paragraphs, tables and image references. Marginal furniture — headers, footers, page numbers, side text — never reaches it, and neither do footnotes or equation numbers. When output="markdown" was requested, blocks can be null and markdown is the only source.
A structured note about degraded evidence — truncation, a partial page, pages left unprocessed when the time budget ran out, a skipped element, a page whose layout scored low or a table read in a loop. Top-level warnings[] plus per-page error fields tell you how complete a result is before you trust it. Each warning carries code, severity (warning or info), message, target and details. Codes: pages_truncated, pages_unprocessed, page_failed, office_converted, tables_spans_expanded, images_truncated, json_rag_failed, dpi_ignored, layout_low_confidence, table_suspect. The last two name a page that has no error and may still miss text; table_suspect says in details.reread whether a second reading replaced the block (kept: it passed the checks and is usually whole, not surely) or its text is still cut short (rejected, skipped, off). The json_rag export lists those pages in metadata.low_layout_confidence_pages and metadata.suspect_table_pages; its chunks carry no mark.
The stack runs in archive-only mode: vllm-paddleocr is not started and no GPU is reserved, so /parse, /ocr and /parse/chunks refuse before reading the upload, and /health reports mode=archive_only with vllm=disabled while healthy. Stored archives, /chunk on saved JSON and Office previews still work; OCR comes back when the stack is started in OCR mode again: no --archive-only / -ArchiveOnly flag, and OCR_ARCHIVE_ONLY unset or false in .env.
/ocr takes one image and one task — ocr, table, formula, chart, spotting or seal — and returns result, task, boxes, model_name, processing_time_ms and warnings. Spotting boxes are axis-aligned envelopes in normalized 0–1000 units, not pixels. When generation stops at the token limit the partial result still arrives with HTTP 200 and a generation_truncated warning; the server never retries it.
A grouping hint between neighbouring blocks — an empty text block can share a group_id with the block holding its text. It is not a block_id and does not change the reading order.
The marginal labels: header, footer, number, aside_text, header_image, footer_image. They describe the page, not its body — keep them as metadata, out of quotations.
Checked against the repository's owning references. This page is an offline explanation; it does not inspect your machine, connect to your services, or change their configuration.
Match each surprise in a result to the field that explains it.
Check the request's output and top-level warnings. When blocks is null the parse ran with output="markdown": the Markdown is the only source — cite by page, say that headers, footers, page labels and side text are absent, and re-parse with output json or both if you need the structure.
An empty text block sharing a group_id with a non-empty block keeps its text there — read the group, not the single block. Empty visual blocks (image, chart, seal) are normal: mention presence and captions, never describe or quote pixel content.
Yes, with a caveat. A per-page error means that page is unreliable or missing while the others returned normally; pages_truncated means only the first pages were parsed at all; pages_unprocessed lists pages never reached before the time budget ran out, while the finished pages still return. Name the gap and never call a partial result the whole document.
A figure_title without an adjacent object is only a possible continuation — its figure or table may live on the next page. Verify matching evidence there; otherwise report the association as unresolved rather than guessed.
No. block_id already is the reading order — including tables, captions and vertical text, which ran right to left on the pages observed. Coordinates are provenance for pointing back at the page, not a sort key.
A page can genuinely hold two articles, or the second doc_title is a subtitle or subject line. Confirm from the content around it before treating it as the title.
The next guide turns this JSON into token-bounded chunks that keep their provenance.
Budgets, section awareness, protected tables and the chunk JSON shape.
Read the chunking guide ↗Which container validates, which GPU recognizes, and what survives a restart.
Read the architecture guide ↗