oneocrDocs
oneocr docs
Everything about OneOcr: getting started, the page model and its JSON, how a page is read, invoices, receipts, PDFs and LLM vision, training, the benchmarks, and the formats.
Start
Getting startedInstall OneOcr for .NET 10, read the text of an invoice image, walk the page model with its boxes and confidences, turn the page into Markdown, and set a default engine. No native binaries, no tessdata, no network.Overview and benchmarksThe README: what OneOcr does, the packages, reading a page, the page model and its JSON, invoices and receipts, PDF, LLM vision with grounding, training, determinism, limits, the models and how they were trained, and the benchmark tables against Tesseract, PaddleOCR, docTR and Apple Vision with their method.Moving from TesseractThis guide maps what you do with the tesseract command line (or a wrapper around it) to the OneOcr API. It is based on Tesseract's public documentation (its manual pages and --help output) and on its observable behaviour, nothing else. Where a setting has no counterpart, the…
The page model
oneocr.page JSONThe JSON form of an OCR result: pages of blocks, lines, words and characters, with the layout elements a layout model can add (regions, tables, key–value pairs). It is written by OcrPageJson.ToJson/Write, read by OcrPageJson.Read/Parse, and is deterministic: the same pages…Local MarkdownOcrMarkdown.ToMarkdown(page, options) (and image.ToMarkdown(), and the same on PDF pages and documents) writes a page of the page model as Markdown without a model or a network. The text is a function of the page and the options only: no clock, no random choice, no culture.…Table structureHow the local reader turns a table on an image page into a Table of the page model: cells with row and column spans, empty cells, and the words in each cell. No member of oneocr.page v1 changes; this document says what the existing members hold for a table the reader…Text normalizationThe library normalizes text in three places: the extraction model's character ids (NFC), the grounding fold (NFKC) and the training agreement check (NFC). The runtime's string.Normalize cannot be used for this: under invariant globalization it leaves non-ASCII text unchanged…
Reading a page
Orientation and deskewWhat the local reader does to a page image before it looks for text lines, so that scans fed in sideways, upside down or crooked are read like upright ones. Every step uses integers or the IEEE basic operations (+ − × ÷ √), so the result is the same on every machine, kernel…The page detectordbnet-lite-v1 is dbnet-lite-v0 with three optional changes. Everything else is as in v0: inputs, outputs, pre- and post-processing, layer types (convolution, 3x3 depthwise convolution, ReLU, nearest 2x upsampling, addition, channel mean, linear), tensor naming, the…CTC decodingInput: per-step class scores (logits, T steps of C classes, class 0 the CTC blank) from a recognizer, and the charset. Output: text and a confidence. Every mode gives the same bits on every CPU path, OS and degree of parallelism.Character language modelA file holds one n-gram model of words per script. The decoder (decoding.md) uses it to rank alternative readings of a text line. It is produced by training/charlm/build_charlm.py and read by CharLanguageModel. All integers are little-endian.Word frequency fileA file holds how often words occurred in running text. The recognizer's word segmentation (oneocr-page-v1.md, "Word segmentation") uses it to take back a space the network put inside a word. It is produced by training/wordlm/build_wordlm.py and read by WordFrequencyModel. All…Numeric rulesThe operation order that makes the library's output bit-identical across CPU paths (scalar, 128-bit vectors, AVX2 and AVX-512), operating systems and degrees of parallelism. A port that follows these rules reproduces the C# results exactly. All arithmetic is IEEE 754 binary32…
Documents, PDFs and LLMs
The extraction modelA small transformer over the words of a page. It labels words; deterministic code joins the labelled words into fields, so a value is always the text of words that are on the page. The container section is in model-container-v1.md, the numeric rules of the kernels in…PDF pagesHow a PDF page becomes an oneocr.page page. All PDF parsing is OnePDF's and all drawing is the OneImage PDF bridge's; this package only converts, decides what to trust, and calls the engine's page entry point (OcrEngine.Ocr) on rendered regions.Grounding LLM outputBehavior of LlmClient.ReadAsync in RecursiveAI.OneOcr.Llm. Everything here is deterministic given the model's answer and the page model: no clock, no locale, no randomness. A port must reproduce it exactly.
Training
Review queueStatus: current. The recognition fine-tuner (OcrTrainer, oneocr train) keeps everything in one work directory, and the review queue is a pair of JSON files around it.Backward numericsHow gradients, the CTC loss and the optimizer step are computed, in an order that makes them bit-identical across CPU paths (scalar, 128-bit vectors, AVX2, AVX-512), operating systems and degrees of parallelism. A port that follows these rules reproduces the C# results…Fine-tuning extractionThe training counterpart of docextract-v0.md, written so that another implementation can reproduce the gradients and the weights. It follows backward-numerics.md (every long sum a 16-lane dot product, everything else separately rounded IEEE operations, no fused multiply-add…
Reference
Model containerStatus: current. Version 1 is version 0 (model-container-v0.md) with format version 1 and one added manifest member, calibration. Writers produce version 1; readers read both. A version 0 file loads and has no calibration: its calibrated word confidence is its raw confidence…Model container, version 0Status: superseded for new files by version 1, which adds calibration. Readers still load version 0 files; they carry no calibration.Page detector, version 0(dbnet-lite-v1 adds an optional stride-16 layout branch and a two-scale orientation head: detector-v1.md.)ChangelogWhat changed in OneOcr 1.0.0, the first release.