OCR-CLI (ocrx)
OCR-CLI is a local Rust command-line tool for extracting structured content from PDF documents with OvisOCR2. It is designed to run locally, keep document data on the host, and produce Markdown-oriented OCR artifacts suitable for further processing by humans or automation.
Status: development preview
This repository is not yet a production release. Version 0.1 is currently being validated on macOS arm64. Runtime reproducibility, PDFium packaging, long-document resource behavior, model quality baselines, and final release licensing artifacts are still being frozen.
Scope
The current v0.1 scope is intentionally narrow:
- Two supported OCR models selected with
--model: OvisOCR3 (default) and OvisOCR2 (fallback). - Local PDF input and page rendering through PDFium.
- Multimodal inference through llama.cpp/libmtmd and a separate
mmprojGGUF file. - OvisOCR2 profiles:
compact,balanced,quality, andreference. - OvisOCR3 profile:
quality(Q8_0; the actually available community conversion set — see the release notes for the freeze table). - Markdown, JSON, progress, resume, and diagnostic workflows exposed by the CLI.
- A macOS arm64 release/Skill packaging path.
Other OCR models are not part of the v0.1 public contract. In particular, the project does not claim support for HunyuanOCR or other model families. The default model is OvisOCR3 (D-50 memory rule: >= 8 GiB RAM runs OvisOCR3 quality, 6-7 GiB automatically falls back to OvisOCR2 balanced, < 6 GiB keeps the floor error; an explicit --model is always honored as-is).
Current implementation status
The repository contains the Rust workspace, CLI entry point, PDFium integration, llama.cpp/MTMD runtime integration, OvisOCR2 model manifest, output types, validation scripts, and an Agent Skill definition. Some production gates remain open; do not interpret the existence of an implementation or test fixture as a production-support guarantee.
Known release work is tracked in docs/plan/pre-development-macos-freeze-plan.md, including runtime revision alignment, PDFium release validation, resource limits, model provenance, and quality evidence.
Requirements
For the current development path, use:
- macOS arm64;
- Rust
1.85or a compatible toolchain selected byrust-toolchain.toml; - a compatible arm64 PDFium dynamic library when running the PDF pipeline;
- the OvisOCR2 model GGUF and its multimodal projector (
mmproj) installed separately.
The packaged archive does not include model weights. Model files are large, revisioned artifacts and are managed separately so that users can verify their provenance and license status.
Build and bootstrap checks
Clone the repository and run:
cargo build --workspace
cargo test --workspace
cargo run -p ocrx -- version
cargo run -p ocrx -- doctor
The repository also provides focused checks under scripts/, including compatibility, regression, release-script, PDFium, and Skill validation helpers.
CLI usage
The main commands are:
# Show the CLI version and available help.
cargo run -p ocrx -- version
cargo run -p ocrx -- help
# Inspect the local runtime and model environment.
cargo run -p ocrx -- doctor
cargo run -p ocrx -- doctor --report json
# Inspect or manage the supported OCR models.
cargo run -p ocrx -- model list
cargo run -p ocrx -- model info ovisocr2
cargo run -p ocrx -- model info --model ovisocr3
cargo run -p ocrx -- model recommend
cargo run -p ocrx -- model recommend --model ovisocr3
# Scan a PDF using the automatically selected OvisOCR2 profile.
cargo run -p ocrx -- scan /absolute/path/to/input.pdf \
--model ovisocr2 \
--model-profile auto \
--non-interactive
For a release binary, replace cargo run -p ocrx -- with ocrx. Use absolute paths for PDF inputs and output directories in automated or Skill workflows. A cancelled scan can be resumed with --resume; --resume and --overwrite are mutually exclusive.
Multiple inputs (or a directory of PDFs) scan as one orchestrated invocation: model verification and loading happen once, every document keeps its own output contract (per-document output directory, document.md, result.json, resume and cancel semantics), and an aggregate scan-summary.json lands in the output root:
# Scan several PDFs (or every *.pdf in a directory) in one invocation.
ocrx scan doc-a.pdf doc-b.pdf ./more-pdfs/ --output-dir /absolute/output/root --non-interactive
With multiple resolved inputs, --output-dir is required and becomes the output root: each document lands in <root>/<stem>-<hash8>/. A document that cannot be read is reported and skipped while the rest continue (non-zero aggregate exit code). A single-input scan keeps the historical behavior (<input-dir>/<stem>-ocr output, page-count failure on a missing file).
Useful scan options include:
--output-dir <DIR> Write artifacts to an explicit directory
--pages <SELECTION> Process selected pages
--model-profile <PROFILE> auto|compact|balanced|quality|reference
--device <DEVICE> auto|cpu|metal|cuda|vulkan
--report <FORMAT> text|json
--progress <MODE> auto|bar|plain|jsonl|off
--offline Do not perform network operations
--non-interactive Disable interactive prompts
--resume Resume an interrupted scan
--overwrite Allow replacing existing output
--keep-pages Keep rendered page images
The exact behavior of model installation, output schemas, and profile selection remains subject to the v0.1 compatibility and quality gates.
Profile selection
Quality differences between the quantized profiles are small: the
OmniDocBench v1.6 full-set baseline puts all four profiles within a 2.4-point
Overall spread (75.6-78.0), and balanced (Q5_K_M) actually beat the F16
reference profile by 2.1 points
(docs/test/reports/omnidocbench-baseline-2026-11-06.md).
Pick a profile by speed and VRAM, not by expected quality:
balanced is the recommended default whenever it fits in memory, compact
for tight budgets. --model-profile auto keeps the memory-floor selection
described above; pass --model-profile balanced explicitly when your machine
could also run a larger profile and you want the fastest decoding tier that
holds the best measured quality.
Custom models (user manifests, v0.1)
Models with the SAME architecture and different weights (community quantizations, Ovis-base finetunes, offline conversions) register as pure data — no rebuild, and the manifest language cannot express anything that needs new code:
# 1. Copy a template and fill in your files.
# assets/manifests/custom-model-template/{remote,local}-manifest.example.json
# 2. Zero-side-effect static pre-check (per-item verdict table).
cargo run -p ocrx -- model check my-model.json # remote pins
cargo run -p ocrx -- model check my-model.json --assets ./gguf # local files
# 3a. Remote registration (download happens at install, after the consent gate).
cargo run -p ocrx -- model register my-model.json
# 3b. Local import (single transaction: hashes pinned from the files (TOFU),
# assets copied, zero network).
cargo run -p ocrx -- model register my-model.json --assets ./gguf
# 4. Install + use (custom installs ALWAYS require consent: interactively,
# or --non-interactive --license-accepted for this one invocation).
cargo run -p ocrx -- model install --model my-model balanced
cargo run -p ocrx -- scan paper.pdf --model my-model -o ./out
Hash one-liners: Windows Get-FileHash -Algorithm SHA256 <file> /
macOS-Linux shasum -a 256 <file> / HuggingFace file rows show the sha256.
ocrx model list appends registered custom models; ocrx model unregister <id> [--force] removes the registration (and with --force
every revision directory). Batch registration is idempotent:
for m in models/*.json; do ocrx model register "$m"; done.
Constraints: profiles come from the frozen vocabulary
{compact, balanced, quality, reference}; asset URLs must be plain HTTPS
(no userinfo, query, or fragment); .gguf suffix required (a suffix is
not a format proof — unsupported quantizations still fail at load).
Custom models never resolve as the implicit default or auto — select
them explicitly with --model.
Windows GPU support (Vulkan)
Windows builds default to the CPU baseline. A Vulkan-enabled binary is built
opt-in and rides the W4.2 evidence path
(docs/test/reports/quality-gate-ovisocr2-draft-v1-2026-10-30.md):
# Build the GPU variant (requires VULKAN_SDK with Bin/glslc.exe on PATH).
cargo build --release -p ocrx --features vulkan
ocrx scan input.pdf --model ovisocr2 --device vulkan --non-interactive
# Package the CPU binary plus a Vulkan variant in one archive.
powershell -File scripts/package-windows-x64.ps1 -GpuPackages vulkan
install.ps1 promotes bin/ocrx-vulkan.exe to the default ocrx.exe when the
machine reports a Vulkan driver and the variant launches (the CPU binary is
kept as ocrx-cpu.exe); otherwise it silently keeps the CPU build. --device auto selects Vulkan only when the backend is compiled in and the probe
reports it; a GPU initialization failure falls back to CPU with a warning.
On the W0.4 30-page gate set, the Vulkan reference scan matched CPU output
page-for-page (mean text similarity 0.9999) at 9.6x the CPU throughput on an
RTX 4090 D. CUDA remains out of scope until the toolkit gate (W4.3) lands.
Model provenance and licensing
OCR-CLI does not bundle model weights in its release archive. The current manifest identifies the following model assets:
| Asset | Source and revision | License/status |
|---|---|---|
| OvisOCR2 base model | ATH-MaaS/OvisOCR2 | Apache-2.0 as declared by the model card |
| GGUF quantization | Abiray/OvisOCR2-GGUF, revision 8a22290a0c42dbcf84739d6d4c2763f877494ae0 |
Apache-2.0 as declared by the model repository; verify the upstream terms before redistribution |
| Multimodal projector | mmproj-F16.gguf from the selected GGUF repository |
Must be kept with its source and license metadata |
| Base-model lineage | Qwen/Qwen3.5-0.8B | Refer to the upstream model card and license |
The machine-readable manifest, including profile sizes, source URLs, and SHA-256 values, is stored at assets/manifests/ovisocr2/. A model license is separate from the OCR-CLI source-code license. Users and distributors are responsible for complying with the terms that apply to each model file they download or redistribute.
PDFium and runtime dependencies
OCR-CLI uses the following important upstream components:
- PDFium, accessed through the
pdfium-renderRust wrapper, for PDF rendering. The recorded macOS/Windows packaging baseline uses community-built binaries frombblanchon/pdfium-binariesbased on Chromium PDFium; check the release manifest for the exact binary revision and notices; - llama.cpp and its multimodal/libmtmd support, accessed through Rust bindings, for local multimodal inference;
- Rust ecosystem dependencies listed in
Cargo.tomlandCargo.lock.
When a release archive contains lib/libpdfium.dylib, the archive must include the applicable PDFium and Chromium third-party notices. PDFium redistribution requires preservation of the relevant copyright notices, license conditions, and disclaimers. The final release must also ship a complete third-party license inventory; see the repository release checklist before redistribution.
Installation and packaging
The current packaging path targets macOS arm64:
OCRX_PDFIUM_LIBRARY=/absolute/path/to/libpdfium.dylib \
bash scripts/package-macos-arm64.sh
The generated archive contains the CLI binary, the OCR-CLI Skill, the PDFium library, and checksums. It does not contain OvisOCR2 weights. For a local source installation:
cargo build --release -p ocrx
bash scripts/install.sh
The installation scripts are still development-preview tooling. Verify the target architecture, PDFium revision, release checksum, model manifest, and third-party notices before publishing an archive.
Agent Skill
The Skill definition is available at assets/skills/ocrx/SKILL.md. It instructs an agent to:
- run
ocrx doctor --report jsonfirst; - use only an installed local OvisOCR2 profile;
- keep PDF and OCR data local;
- use absolute input and output paths;
- request human verification of OCR output and extracted images.
The Skill does not download model files automatically.
Limitations and safety
OCR output is probabilistic and may contain incorrect or incomplete text, formulas, tables, reading order, or visual-region coordinates. Results for important documents must be manually reviewed. Do not rely on OCR-CLI as the sole source of truth for legal, financial, medical, compliance, or archival decisions.
PDF complexity can affect memory use and runtime. Encrypted PDFs, malformed PDFs, unusual page sizes, and very long documents may require additional validation. The project does not currently promise a stable resource ceiling for every real-world PDF.
The official OvisOCR2 model card also notes that parsing errors can occur despite filtering and quality-assurance procedures. See the OvisOCR2 model card for model-specific limitations.
Acknowledgements
OCR-CLI would not be possible without the following projects and contributors:
- ATH-MaaS/OvisOCR2 and the authors of the OvisOCR2 technical report;
- Abiray/OvisOCR2-GGUF for the selected GGUF quantization and multimodal projector distribution;
- Qwen/Qwen3.5-0.8B for the base-model lineage identified for OvisOCR2;
- llama.cpp and its contributors for local inference and libmtmd;
- PDFium and Chromium contributors, the
pdfium-renderRust wrapper, andbblanchon/pdfium-binariesfor the community-built PDFium binaries used by the recorded packaging baseline; - the Rust compiler, Cargo, and the open-source crates listed in the project dependency metadata.
See THIRD_PARTY_NOTICES.md for principal dependency links and release attribution requirements. It is a summary; binary releases still need a complete, version-specific inventory of bundled software and applicable notices.
If you use OvisOCR2 in academic work, please cite the technical report using the citation provided by the official model card.
License
The OCR-CLI source code is intended to be distributed under the Apache License, Version 2.0, as declared in the Rust workspace metadata. Principal third-party components and the release review checklist are documented in THIRD_PARTY_NOTICES.md. The repository must still include the complete Apache-2.0 license text and a release-specific review of third-party notices before a public release is published.
Model weights, PDFium binaries, llama.cpp-derived components, and other dependencies may be subject to separate licenses and notices. See the upstream sources and the final release's third-party attribution files for the terms that apply to each component.
Further documentation
Implementation plans and internal development notes are maintained in the repository for contributors but are not part of the end-user documentation.
No comments yet. Be the first to write one.