Local OCRdoc/{zh,en}/design/plugins/local-ocr.md

Local OCR

Status: built 2026-11-29 as slices S5b and S5c of the media parsing research (P100, ADR 0018), shipped together (owner's decision). Verified natively on macOS arm64 only; Linux (am

Status: built 2026-11-29 as slices S5b and S5c of the media parsing research (P100, ADR 0018), shipped together (owner's decision). Verified natively on macOS arm64 only; Linux (amd64, arm64) and Windows (amd64, arm64) are cross-compiled with CGO_ENABLED=0 and not run (section 7). Columns, the memory bound and recognition languages followed on 2026-12-01 (P100, the local OCR follow-up; sections 4, 5 and 7); scanned layout and table structure on 2026-12-04 (P100, media harness review M-16; sections 2, 4, 5, 6, 8 and 9); formulas as LaTeX the same day (P100; sections 1, 4, 5, 6, 8 and 9), and the same day the columns of a scanned page's regions (section 4); vertical Chinese and Japanese text on 2026-12-05 (P100; sections 2, 5, 8 and 9).

1. What it does

Without an image model (media.models.image unset), the builtin parser ocr of the plugin parse-ocr reads the text of images and of scanned PDF pages on this machine, with the PP-OCRv6 small detection and recognition models and the PP-OCRv5 text-line orientation model on ONNX Runtime 1.32.0. A configured image model keeps precedence: cloud first, local as the fallback (owner's order). A PDF page with a text layer was passed through untouched when this was built; since 2026-12-03 local OCR also reads the drawing of every such page, natively rendered, to check its layer (PDF renderer); nothing is installed or fetched for it. With the layout model PP-DocLayout-S and the table structure model SLANet_plus, installed with the others, a page is read by its regions: titles and headings, paragraphs, list items, tables as rows of cells, figures as markers with their captions, headers and footers apart (section 5); without them it is read line by line as before. With the formula model PP-FormulaNet_plus-S, installed with them too, the formulas the layout model finds are read as LaTeX: $$...$$ on a line of its own for a formula set apart, $...$ inside the sentence for one in a line of text (section 5); without it they read as text. A PDF text layer that reads well keeps its math as it is, without $; a garbled page is read from its image like any other, formulas included. A parse never downloads anything; the runtime and the models are installed with the release (section 6).

Two settings apply (owner's choices): media.ocr.language, the recognition language when a call names none, auto by default (the PP-OCRv6 model, which reads Chinese, English and Japanese), and media.ocr.max_memory, the bound of the worker's memory, 2 GiB when unset, at least 512 MiB. A call names a language with the media tool's language argument or orquelo media parse --lang CODE. The codes are auto, zh, en and ja (all the default model), ko (Korean), latin (Latin-script languages such as French, German or Vietnamese), cyrillic and ar (Arabic), as the manifest lists them (plugin.ParserSpec.Languages). Any other code is refused with media.language, naming it and the accepted ones: media.ocr.language when the Host starts, in serve --preflight and in media parse -c; --lang before the file is read; the tool's argument as an error the model can correct, for example --lang: "tlh" is not a recognition language here; use one of auto, zh, en, ja, ko, latin, cyrillic, ar. The parse cache keys on the language and on a configured bound, so a file is read again under other settings.

2. Call chain

text
media tool / model boundary / orquelo media parse
  → parsing.Service.Parse (internal/host/parsing)
      image, no image model: wants "ocr" → first allowed parser producing it: ocr (tier local)
      PDF: pdf parser → each scanned page without text → PageImage → Parse(image, Want ocr)
  → parse-ocr Parse: checks its files, reads the EXIF orientation → modelworker.Proc.Call → orquelo-onnx ocr worker (stdin/stdout frames)
      → decode → turned as shown (Image.Orient) → ppocr.Pipeline: detect → crop → orient → recognize → columns of vertical text read again → paragraphs
      → with the layout models: Structure: regions → each table's cells → each formula's LaTeX → lines placed → items in reading order
  → media.v1 Document: a note on how it was read, then the items as blocks (heading, paragraph, list_item, table, figure, header, footer), else the paragraphs
  → a PDF: the scanned pages' headers and footers kept once across them (media.Running), figure refs put on their page

An image read for its own sake gets a note that it is an image, its size, that the text below was read by local OCR and may contain recognition errors, and that the model has this text, not the image. A scanned page gets the note (scanned page: the text below was read from its image by local OCR, PP-OCRv6, and may contain recognition errors; you have this text, not the image). With no text found, the note says so.

The Service asks an image for ocr itself only when no image model is configured and the caller wanted nothing else; when that read fails (local OCR not installed, a worker failure), the next parser of images (image) describes the file and a note names why its text could not be read. A scanned page that cannot be read keeps a note naming the reason, and the document is partial, as in S5a. A document holding a step that failed as media.unavailable or media.timeout is not cached, so it is read once OCR is installed.

3. Components

PackageRoleState it owns
internal/host/parsingOrchestrator: what a parse wants (wanted), the choice (choose: model parser with a model, else the first parser giving what is wanted, else the first that reads the type), the fallback, transience, CheckAllow, CheckLanguageNone beyond the parse
plugins/parse-ocrBuiltin parser: checks its files, turns the worker's answer into a DocumentIts modelworker.Proc
internal/modelworkerThe model worker shared with local speech: file layout and checks (Check), frames, the process (Proc); serve is the worker's sideThe worker process
plugins/parse-ocr/wireContract between parser and worker: the file layout and the frames—
plugins/parse-ocr/worker, cmd/orquelo-onnxThe task ocr of the model worker: loads the models once, answers one image at a timeIts ONNX sessions
plugins/parse-ocr/ppocrThe PP-OCR pipeline and the page's structure (Structure); the six models are providers behind ppocr.Model, ppocr.Outputs and ppocr.Generator—
pkg/media (Running, Region), pkg/media/imageprep (Crop)Running headers and footers kept once, shared with pdftext; a figure's region as a Block.Ref; its picture cut from the image—
pkg/onnxONNX Runtime's C API through purego: library, environment, sessions, float32 tensors in and float32 or int64 outThe library's objects

The Host binary does not import pkg/onnx or purego (go list -deps ./cmd/orquelo); only orquelo-onnx does. Builtin parsers get their dependency directory as plugin.Env.DepsDir: deps/<plugin> under config.ShippedDeps().

4. Worker protocol and lifecycle

orquelo-onnx ocr DIR [MAX_BYTES] (since S6 the model worker shared with local speech, one process per task; built as orquelo-ocr in S5) loads ONNX Runtime from beside its executable and the models from DIR, and reads and writes frames on stdin and stdout: a 4-byte big-endian length and that much JSON, at most 64 MiB. Its first frame is Ready {runtime} or Ready {error: {code: media.unavailable, message}} naming the file that did not load. Each Request {image, orientation, lang, max_memory} (PNG, JPEG, GIF, BMP, TIFF or WebP bytes; the photo's EXIF orientation, 1 to 8, or 0 when its pixels are already upright; the recognition model, "" for the default or ko, latin, cyrillic, ar; the bound) gets one Response {width, height, lines: [{text, score, box}], paragraphs, paragraph_boxes, items: [{kind, text, rows, ordered, box, cells}], structure_error} or {error: {code, message}} (items only with the layout models, section 5; paragraph_boxes, an item's box and a table item's cells are where each stands, x0, y0, x1, y1 in pixels of the image turned upright, which the parser gives as media.v1 box and cell_boxes; structure_error names why a page's regions could not be read, the page then read line by line): media.malformed for an image it cannot decode, media.too_large above 40 million pixels or when the image's copies alone would pass the bound (about 256 MiB for the worker and its models plus 12 bytes a pixel for an RGB image), media.unavailable for a recognition model that does not load, media.parser_failed for a pipeline failure. A panic is that image's failure; the Go heap's soft limit is half the bound. The worker loads the default recognition model when it starts, the layout and table models with it when both are installed (neither when one is missing), the formula model's tokenizer with them, the formula model itself for an image on its first formula from its file, closed with the image, its memory given back to the system before and after (serve.Trim: Go's heap, and malloc's free pages on macOS and with glibc); it holds 450–700 MB while open, so an image whose copies leave less than 1.5 GiB of the bound (for the networks' buffers and the model) reads its formulas as text, and another language's recognition model on its first image, then keeps it.

Memory bound. modelworker.Proc.CallBounded starts the worker with the bound as MAX_BYTES (a worker running with another bound is stopped first), and the worker holds itself to it (serve.Bound): a watchdog reads its peak memory every 10 ms and, past the bound, ends the process with exit status 86 (modelworker.ExitMemory), after a stderr line naming its use and the bound; the Host names the image media.too_large (it needs more memory than local OCR may use (2048 MiB); the worker was stopped; it said: …) and goes on, and the next image starts a new worker. The process may pass the bound by what it allocates in 10 ms (568 MiB seen under a 512 MiB bound, reading an A4 page at 300 dpi). Where the system enforces a limit of its own, an allocation past 1.5 times the bound also fails, for memory allocated faster than the watchdog reads (section 7). What the networks take grows with the lines' width, so a recognition batch holds fewer than six lines when they are wide (section 5): measured on macOS arm64, the worker peaks at about 1.3 GB on an A4 page scanned at 300 dpi and about 1.9 GB on a 6,000 × 6,200 page, the largest allowed size; a 60,000 × 60,000 PNG is refused by its pixel count before it is decoded.

modelworker.Proc starts the worker on the first image, with the inherited environment of plugin processes (internal/childenv), and keeps it while images come: the models load once (about 0.2–1.5 s), later images take only their own time. One image is read at a time; a read waiting for its turn past its deadline ends with media.timeout. A read that overruns its deadline kills the worker (media.timeout); a worker that dies names its last stderr lines (media.parser_failed); either way the next image starts a new one. After five idle minutes its stdin is closed and it exits. It also exits when the Host does, at the end of its input.

5. Pipeline

Ported from RapidOCR v3.10.0 (python/rapidocr) and PaddleOCR (both Apache-2.0; THIRD_PARTY.md):

  • ◆EXIF orientation (Orquelo's own): before anything else the decoded image is turned the way it is shown, for all eight values: 2 mirrored, 3 upside down, 4 flipped top to bottom, 5 and 7 mirrored across a diagonal, 6 a quarter clockwise, 8 a quarter counter-clockwise; width and height stay the stored size, as the EXIF properties give it. A HEIF photo is not turned again: ffmpeg already applies its irot and imir when it makes the PNG (checked with ffmpeg 9.1), so the parser sends 0.
  • ◆Image bounds (RapidOCR): the longer side at most 2,000 px, the shorter at least 30 (a thin strip only so far that its length stays bounded), multiples of 32; a strip wider than eight heights is padded above and below.
  • ◆Detection: the shorter side brought up to 736, multiples of 32, at most 4,000; values (v/255 − 0.5)/0.5, BGR; DB post-processing with thresh 0.3, box_thresh 0.5, unclip 1.6, dilation, at most 1,000 boxes: 8-connected regions, convex hull, minimum-area rectangle, mean probability inside, grown by area × 1.6 / perimeter. These are RapidOCR's settings; the model's inference.yml says ImageNet normalisation, 0.2, 0.45 and 1.4, which on the corpus merged neighbouring lines.
  • ◆Cut-out: a perspective warp of each box, bicubic, border replicated; turned a quarter counter-clockwise when 1.5 times taller than wide.
  • ◆Orientation: PP-LCNet_x0_25_textline_ori, lines squeezed to 80 × 160, six to a batch; turned when 180 degrees scores above 0.9.
  • ◆Recognition: height 48, width at least 320 and the widest line of the batch, six to a batch sorted by width, fewer when six would be wider than 7,680 pixels in all (Orquelo's own: the network takes about 75 KiB per pixel of a batch's width, 2 GB for six lines 4,000 wide); greedy CTC over the dictionary with the blank first and a space last (18,710 classes for PP-OCRv6); lines under 0.5 mean confidence are dropped. The other languages' models are PP-OCRv5 mobile recognition models with the same input and decoding and their own dictionaries; the Arabic model gives a line as drawn, left to right, which is turned around with runs of Latin letters, digits and their punctuation kept as read (PaddleOCR's pred_reverse).
  • ◆Reading order (Orquelo's own): the page is set upright by the turns most lines needed (sideways and upside-down pages read from their top), straightened by the median slant of the lines, pieces on one row joined left to right, rows top to bottom, a paragraph broken at a gap of 0.8 row heights; the pieces of a row mostly in Arabic or Hebrew letters are joined right to left.
  • ◆Columns (Orquelo's own, an XY cut on the upright line boxes, ppocr/columns.go): the gutter is the vertical line the fewest lines cross, by their height, with at least two lines wholly on each side. It is taken when the lines crossing it are less high together than either side's lines, both sides lie beside each other over at least half of the shorter one's height, and the sides look like columns: each side's lines at least five line heights wide at the median (columns of text), or columns of short lines alike, at least three lines a side, their median widths within 1.5 times of each other and at least one line height between where the median line of the left ends and that of the right starts (the cells of a table, as Quick Look renders an HTML table). So a column of prices beside their items stays one column read row by row, the prices being narrow beside the items. The lines crossing the gutter (a full-width heading, a line between two sets of columns) split the page into bands, each read before the columns below it, as is a line above the other side's lines set off from its own side's by a paragraph gap (a heading centred over some of the columns); in each band the left side is read before the right, each split again at a gutter of its own, so three or more columns read left to right. A page without such a gutter is one block, read as before. Right-to-left column order of horizontal text is not built; columns of vertical text read right to left (below).
  • ◆Vertical text (Orquelo's own, ppocr/vcolumn.go, reread.go, marks.go): a box cut out turned a quarter counter-clockwise and not turned over (a column read top to bottom, as PaddleOCR's get_rotate_crop_image turns a box 1.5 times taller than wide) whose reading is mostly Chinese or Japanese is checked by its ink, the cut-out's columns of pixels holding the darker tone (the lighter on a dark page): the pitch of its characters, the median distance of characters read next to each other with no other ink between, must be at most 1.28 times the width of its widest character. Short horizontal lines stacked one above another that detection joined into one box stand a line height apart and read as a line, as before. A column is read again, in one batch with the others: its cells (one per character read, one per run of ink nothing was read for, dots joined to dots and other ink to other ink within a pitch) set upright side by side as one horizontal line, each cell's ink at the bottom left of its cell, where horizontal setting puts small kana and stops; and each run of ink nothing was read for by itself, turned as the line and upright. A character read takes the size that line reads it in (small or large kana), and its reading there when its own confidence was under 0.5 and that one is higher. Ink nothing was read for is a bracket, parenthesis, dash, ellipsis or wave dash as read turned; a full stop (a ring read as o or 0), comma, colon or middle dot as read upright; a bar along the column (at least 0.45 widths long, at most 0.3 thick) a long-vowel mark beside kana, else a dash, one per pitch of its length; three dots an ellipsis and two a two-dot leader (dots beside an ellipsis read are part of it); else a Chinese or Japanese character read with 0.8 confidence by itself or in that line; anything else is left out. A comma at the top right of its cell read as an apostrophe is ,. A column under three characters long whose reading is not Chinese or Japanese (a column's last characters, read turned with little to go on) is read the same way and kept only when at least half its cells read as Chinese or Japanese characters. A column's confidence is the higher of its own and that line's. The vertical presentation forms U+FE10–U+FE19 and U+FE30–U+FE4F come out, from any line, as the characters they stand for (︑ as 、, ﹁ as 「, ︱ as —, ︽ as 《).
  • ◆Vertical pages (Orquelo's own, ppocr/vertical.go): columns sharing half the shorter one's rows and at most 1.5 widths apart are a block, with the lines not wider than high among them (a column of one character); blocks sharing rows are one. Ruby, a line at most 0.65 of a column's width beside it within its rows (at most 0.6 widths away, or 0.3 into its box), is left out. A column with two horizontal lines or more starting within its width beside it on its rows is the first characters of stacked lines and reads as a line. A page of blocks only reads as a page turned a quarter: columns right to left, each top to bottom, tiers top to bottom, a paragraph broken at a gap of 0.8 column widths. On a page with horizontal lines too, each block of two columns or more is one piece where it stands among them, placed by the reading order above (a heading over it before it, a caption under it after) and read in its own direction there; such a page is not read by regions. A single column on a horizontal page is a line among the others, as before.
  • ◆Regions (PP-DocLayout-S, PaddleX): on an upright page (most lines not turned) without a block of vertical text, with both layout models installed, the page is scaled to 480 × 480 without keeping its shape, RGB, ImageNet-normalised; the network's own NMS keeps boxes over 0.3, given back in its input's pixels (its scale factor input is 1) and scaled to the page. Orquelo keeps tables, figures (image, chart, seal), headers and footers (with header and footer images, and page numbers told by where they stand) at 0.5 or more, titles and headings at 0.4, captions and text at 0.3, and of two boxes mostly the same (80 % of the smaller) the more likely.
  • ◆Columns of regions (Orquelo's own, an XY cut on the region boxes, ppocr/bands.go): with regions, the line gutter above is often not found on a page whose lines across it (a title, a lead paragraph, a list) outweigh its columns. So the boxes of what is read in the flow (each region read, table or figure, and each line of no region) are first put in bands, a box in the band of any box it shares a row with. A band with boxes on both sides of a gap starts a set of columns, which goes on through the bands that leave some of that gap open, to the last with boxes on both sides, if the lines in those bands read as columns by the test above, at least two a side, and each side's median line spans at least 0.6 of that side's width: lines of text fill their column, while a region of labels beside one of their values (a form, a list of specifications) does not, and is not cut. So paragraphs side by side whose gaps line up are not read across, and items with their prices still are. A band crossing the gap (a title, or a figure or table across the columns) ends the set. Bands with boxes on one side only are in the set between bands of both (a heading beside a gap in the other column); next to the set, before or after it, they are in it up to the widest space between bands on the way to the band that closes the gap; at the page's end all of them, at its top those less than a paragraph gap (0.8 line heights) apart. A column starting a little higher or ending lower keeps its lines, a heading over a list across the page goes with the list, and a box over one column at the page's top (an invoice's number and dates) is read first. The page is cut between the sets and the bands outside them, and each set at its widest common gap, each line, table or figure going where its middle lies; the cuts repeat within each part, and each part is read in the line column order above. A page with no set of columns reads as one part, as before.
  • ◆Reading by regions (Orquelo's own, ppocr/structure.go): each line goes to the table or figure holding half of it, else to the region holding most of it, at least half; lines outside every region read as before, so a region the model misses loses no text. Tables and figures are placed as wholes among the lines in the order of the columns of regions and, within each part, of the lines' columns (a whole by its top, a line by its middle, the lines of one row left to right), and a run of lines of one region reads as its paragraphs: a title as a level-1 heading, a heading as level 2, text as paragraphs, a paragraph whose first row starts with a bullet (•, ·, ▪, -, * and the like) or with two rows numbered (1., 2), (a)) as list items. Headers come first and footers last, as header and footer blocks on a scanned page (the Host keeps those standing on two pages or more once, without page numbers, by the rule of a PDF's running headers, media.Running; one on a single page reads as a paragraph) and as paragraphs on an image file.
  • ◆Tables (SLANet_plus, PaddleOCR; its TableLabelDecode ported): the table's region, BGR, its longer side scaled to 488, ImageNet-normalised, padded to 488 × 488 with zeros; the network writes HTML structure tokens and, for each cell it opens, a box in fractions of the padded square. Cells fill a grid with their colspan and rowspan; each OCR line goes to the cell it overlaps most, else the nearest; a merged cell's text stands in its first place and the places it covers are empty; the first row is the header. A structure with fewer than two rows or two columns holding text is not a table, and its lines read as text.
  • ◆Figures: a figure region is a figure block where it stands, [figure N: caption], its caption the caption region within three caption heights above or below it and beside it, else (the model often labels a caption text) the nearest single line so placed, of a text region or of none, that starts like a caption (Figure 3, Fig. 2, Plate 7, 图 1) or stands below the figure and is narrower than it; the caption is read only there; words read inside it (an axis label) follow it as text, shapes read as characters (a bar read as _) are left out. A figure covering more than half the page (a photo of a document), one under 48 pixels a side (media.MinFigureSide) or one whose words cover more than 30 % of it reads as text. Its Ref is region/X0,Y0,X1,Y1 in the image turned upright (media.Region), on a scanned page page/N/region/… (set by the Host); a model that sees images gets it cut out (imageprep.Crop, PNG): from an image file by ocr (plugin.Figurer), from a page by the Host through the PDF parser's PageImager.
  • ◆Formulas (PP-FormulaNet_plus-S, PaddleOCR; PaddleX's pre- and post-processing ported): PP-DocLayout-S's formula class (0.5 or more; not merged with the text region holding it) is cut out, cropped to its ink, scaled to fit 384 × 384 and centred on black, grey, normalised by 0.7931 and 0.1738; the network writes the tokens, which are decoded as UniMERNet's byte-level BPE, Chinese taken out of \text{} and spaces kept only between letters (PaddleX's spacing rule without its special case inside \mathrm{} and \text{}). A formula with a line of text on its row (its middle within the line's height, within 1.5 line heights of it; an equation number such as (1) does not count) is inline: it stands among the lines as $LaTeX$, a line it cuts is read again in its parts left and right of it, and a comma or stop inside its region goes after the closing $. Any other is a display formula, an item formula of $$LaTeX$$ where it stands. OCR's own reading of the formula is dropped. The layout model finds most display formulas but only some inline ones; the others read as text. Without the model, or where it writes nothing, the region reads as text.
  • ◆A failure of any of these networks leaves the page read line by line, logged as ocr.structure_failed.

6. Installation

Owner's decision (2026-11-29): local OCR is installed with the release and deployment, never by a parse. scripts/shipped-deps.txt lists what ships in deps/<dir>/ per platform, each file with its sha256 and source: in deps/onnx/, shared with local speech, the worker built from this repository and onnxruntime/ with the library, its LICENSE and ThirdPartyNotices.txt from the NuGet package Microsoft.ML.OnnxRuntime 1.32.0 (MIT); in deps/parse-ocr/models/ the three models and the dictionary from RapidAI/RapidOCR v3.10.0 on ModelScope (Apache-2.0), and from the same release the PP-OCRv5 mobile recognition models and dictionaries of Korean (korean_PP-OCRv5_rec_mobile.onnx, 13.5 MB), Latin (latin_…, 7.9 MB), Cyrillic (cyrillic_…, 8.1 MB) and Arabic script (arabic_…, 8.0 MB), 37.5 MB in all; and the layout model PP-DocLayout-S (models/PP-DocLayout-S.onnx, 4.9 MB, Apache-2.0, PaddlePaddle's model as stefanj0/PP-DocLayout-S-ONNX on Hugging Face exports it with paddle2onnx, commit 7e851b9; its boxes matched the Paddle model's within 0.0002 on the test pages) and the table structure model SLANet_plus (models/SLANet_plus.onnx, 7.8 MB, Apache-2.0, PaddlePaddle's own ONNX export on ModelScope), installed by the same step; and the formula model PP-FormulaNet_plus-S (models/PP-FormulaNet_plus-S.onnx, 233 MB, Apache-2.0, PaddlePaddle's model as RapidAI/RapidDoc on ModelScope exports it to ONNX, commit 3ca91a8, one graph with the decoding loop inside; its tokens matched the Paddle model's on the five test formulas) with its PaddleX configuration (models/PP-FormulaNet_plus-S.json, 4 MB, which holds the tokenizer, from PaddlePaddle on Hugging Face). scripts/shipped-deps.sh DIR [os/arch] builds and fetches them into DIR/deps/, each fetched file checked before use and kept in a cache ($ORQUELO_DEPS_CACHE, else ~/.cache/orquelo/deps); --seed SRC adds files already downloaded.

  • ◆scripts/release.sh runs it for each archive, so every release archive holds deps/onnx and deps/parse-ocr for its platform (about 65–75 MB more per compressed archive with the language models, and 185 MB more with the formula model); orquelo install and make install-local unpack it into releases/<version>/ with the rest.
  • ◆A binary built from source finds its deps/ beside it: make deps puts them beside bin/orquelo, or scripts/shipped-deps.sh DIR beside a binary in DIR.

Where a file is missing, a parse fails with media.unavailable naming it, where it was looked for and how to install it, for example: local OCR is not installed: the ONNX Runtime library (onnxruntime/libonnxruntime.dylib) is missing from …/deps/onnx; it is installed with an Orquelo release ….

Plugin prerequisites (download steps) were not used: they belong to an instance and install into a configuration's state directory, while builtin parsers need no instance, and orquelo media parse runs without a configuration.

7. Platforms

PlatformState
macOS arm64Built, unit, integration and e2e tests run here
Linux amd64, arm64; Windows amd64, arm64Built with CGO_ENABLED=0; not run (no such machine here); the release has no Windows arm64 archive
Memory boundmacOS: the watchdog on the peak resident size (getrusage ru_maxrss) and the image estimate; macOS enforces neither RLIMIT_AS nor RLIMIT_DATA on memory malloc maps, so there is no hard limit. Linux: the watchdog on the peak resident size and RLIMIT_DATA (private writable memory, Linux 4.7 or later) at 1.5 times the bound. Windows: the process puts itself in a Job Object of its own whose process memory (committed) is capped at 1.5 times the bound, and the watchdog reads its peak committed memory from it. Run on macOS arm64 only (a test worker taking memory under a 256 MiB bound); the Linux and Windows code is cross-compiled, not run. An allocation refused by the hard limit ends the worker as a failure (media.parser_failed with its last words), not media.too_large The formula model's serve.Trim was run on macOS only; on Linux it calls glibc's malloc_trim (nothing with another libc), on Windows it returns Go's heap only.
macOS amd64Unsupported: ONNX Runtime 1.32.0 has no Intel Mac build. The manifest's platforms leave it out, so there is no ocr parser and images and scans behave as before; media.allow naming ocr or parse-ocr is refused by name when the configuration loads, in serve --preflight and in media parse -c

8. Evaluation

Against RapidOCR 3.10.0 (Python, onnxruntime 1.32.0) with the same four model files, on 20 rendered images with known text (English and Chinese, 14–36 px, five of them upside down) and 23 scan images taken from the OCRmyPDF files of the PDF corpus:

  • ◆Rendered images: character error rate 0.000 for Orquelo, 0.164 for RapidOCR, all of it on the upside-down images, which RapidOCR reads bottom line first.
  • ◆Scans: nearly the same characters read by both. The share of characters one reads and the other does not is 0.0011 at the median and 0.0025 on average, apart from a photo with no text where Orquelo reads one stray character (with it, 0.048). In reading order the difference is 0.165, almost all of it on three sideways or upside-down pages and a skewed one, which Orquelo reads from their top and RapidOCR does not.
  • ◆Time: 47.6 s for the 43 images against RapidOCR's 46.6 s, models loaded once.
  • ◆Formulas (2026-12-04): five formulas drawn by Chrome from MathML (Times, 40 px), each read alone, took 70–130 ms each on macOS arm64 once the model was open (opening it takes about 0.35 s, once per image with formulas). Three read right: E = mc² as E=m c^{2}, the quadratic formula as \begin{array}{r}{x=\frac{-b\pm\sqrt{b^{2}-4a c}\;}{2a}}\end{array} and a 2 × 2 matrix as A=\left(\begin{array}{c c}{a}&{b}\\ {c}&{d}\\ \end{array}\right); two did not: the sum as \textstyle\sum_{i=1}^{n}i=\frac{n(n(1+1))}{2} and the integral as \textstyle{intint_{0}^{\infty}e^{-x^{2}}d x=\frac{\sqrt{\pi}\ }{{}^{\frac}2}}. PaddleX with the Paddle model reads them the same way, apart from small differences of scaling (the sum as n\ n(n+1)); the ONNX export wrote the Paddle model's tokens exactly. On rendered pages E = mc² read right as a display and inline, an inline sum as above, and the quadratic formula right on the dense A4 pages (19 px type at 300 dpi) but not on a sparser page (26 px: x=\frac{-boldsymbol b pmpm\sqrt{\boldsymbol{b}^{2}-4c}\mathrm{~.~}}{2a}). orquelo media parse of a page with formulas took 1.4–1.7 s against 0.9–1.0 s without the model, and three A4 pages at 300 dpi with three formulas each 9.0–9.3 s against 7.2–7.6 s; the worker's peak was 1.6–1.8 GiB on those pages against 1.4 GiB.
  • ◆Layout and tables (2026-12-04): on five A4 pages rendered at 150 dpi (a report with a ruled table, three pages with one header and footer, a chart with its caption and a bulleted list, plain paragraphs, a delivery note), reading by regions took 29–100 ms a page beside 740–960 ms for detection and recognition (3–12 % more: about 30 ms for the layout, 60–70 ms a table), on a loaded macOS arm64 machine, and the worker's peak memory rose by about 60 MB. Both tables read cell for cell, the header and footer stood once, the chart became a figure with its caption, and the page of paragraphs gained no table or figure. Not yet scored on a corpus of scanned tables (TEDS, cell F1).
  • ◆Vertical text (2026-12-05): on ten pages drawn by Chrome in writing-mode: vertical-rl (four columns of simplified Chinese in Songti SC, six of traditional Chinese in Songti TC, Japanese in Hiragino Mincho with brackets, commas, full stops, ellipses, small kana, long-vowel marks and furigana, a nine-column page of the same with 『』 and a dash, a page of a horizontal heading, vertical columns and a horizontal caption, four pages of kana and their small forms in four fonts) and a horizontal page of short lines stacked closely, orquelo media eval gave a character error rate of 0.104 on average against 0.299 before: the Chinese pages and the Japanese page and the mixed page 0 (0.154, 0.057, 0.322 and 0.589 before), the nine-column page 0.008 (0.192; a rare kanji under its furigana is lost), the kana pages 0.12–0.21 (0.14–0.50; small vowel kana are still read large in some fonts), and the stacked lines the same as before (0.390, its lines' text and order unchanged). On the comparison corpus (75 files, the two vertical PDFs among them with a text layer, no scans) every file scored the same before and after. A nine-column page took 1.8–2.6 s to orquelo media parse (the worker started each time) against 0.8–1.1 s before: the columns are read a second time.

The comparison was run by hand with scripts outside the repository. orquelo media eval now scores images too, with no new flag or layout: photo.jpg against photo.txt beside it, by local OCR, only the recognised text and not the notes, with the same metric as other files (CER for a mostly Chinese, Japanese or Korean reference, else the normalised distance). An image that cannot be decoded scores 1 and its line names the reason; a file whose reader is not installed here (media.unavailable, such as local OCR without its worker or models, which the Host meets by falling back to image) is skipped, naming what is missing.

9. Limits

  • ◆Vertical text is read with the recognizer's own model, turned: ruby that detection joins into its column's box reads within the column; small vowel kana are read large in some fonts; Latin letters or digits set upright or across inside a column (tate-chu-yoko) are not handled apart; a column is told from stacked lines by its pitch, so vertical text set with wide letter spacing (more than about a quarter of a character) reads as lines. Measured on rendered pages only (section 8), not on scans.
  • ◆The worker belongs to the builtin plugin, which isolates the runtime as the native plan asks; it is not a process plugin anyone can install. Process parsers that anyone can install, speaking parser/parse and reading through host/read_artifact, are built since 2026-12-03 (parser protocol); local OCR does not use them.
  • ◆The memory bound is held by a watchdog, with a hard limit by the system on Linux and Windows only (section 7).
  • ◆Without the layout models, columns are found from the line boxes alone, and a table of two wide columns, or of two columns of short cells alike in width, reads column by column. The layout model is PP-DocLayout-S, the smallest of its family: PP-DocLayout_plus-L finds more regions but took 1.5–2.7 s a page here on the CPU against 0.05–0.1 s. It misses some regions, whose lines read as text, and has no list class (lists are told by their bullets or numbers). Cells take their text from the page's OCR lines, so a line the detector draws across two cells goes to one; a table that ends a page and goes on at the top of the next under the same header is one table, joined by the Host (media.TablesAcross; a page number read as text that ends two pages or more is left out as a footer's is, media.Running), but one going on with its rows only is not, as the readings give no positions; a formula the layout model misses (most inline ones) reads as text, and PP-FormulaNet_plus-S, the small model, misreads some formulas (section 8; PP-FormulaNet_plus-M read all five but takes 1.8 GB, too much for the 2 GiB bound); a page turned sideways or with a block of vertical text reads line by line. A page's text layer checked against local OCR (the PDF renderer) is read with the regions too. One recognition model per call: a page mixing Korean and Chinese, say, reads one of them well. The language is chosen, never detected.
  • ◆HEIC. A HEIF photo (HEIC, as iPhones take them) is told by its bytes, the ftyp brands heic, heix, hevc, hevx, heim or heis (image/heic) or mif1 or msf1 without them (image/heif); avif makes it a still AVIF (image/avif, its size read the same way, review M-04) and avis an AVIF image sequence, read as a video, so a .heif or wrongly named file is read too. Go has no HEIC decoder, so ocr has ffmpeg (internal/ffmpeg, shared with parse-video) turn its first picture into PNG and reads that (the owner's choice); the width may come out a pixel narrower. Without ffmpeg it returns media.unavailable naming ffmpeg and how to install it, and the Host falls back to image, which gives the size from the primary item's ispe property and the same EXIF as a JPEG (camera, date taken, orientation, GPS) from the Exif item, both read by pkg/media/bmff without decoding. An image model that takes HEIC gets the file as it is.