Conversation
… set
Add OcrModelSet so the selective-OCR path can load a different pinned,
checksum-verified model set. PpOcrV6Small stays the default; the new
PpOcrV5Korean set pairs the script-agnostic PP-OCRv5 mobile detector with
the Korean PP-OCRv5 mobile recogniser and its dictionary (all 11,172 Hangul
syllables plus Latin letters and digits, ~18 MB), published with the
oar-ocr v0.3.0 release. The PP-OCRv6 Small dictionary has no Hangul, so
Korean scanned pages previously came back empty.
- OcrOptions::model_set / OcrModelSet::{id, parse, manifest}
- PP_OCR_V5_KOREAN manifest; engine cache and model cache are keyed per set
- pdf2md --ocr-model-set pp-ocrv5-korean
- docs: ocr-runtime model-set table, rust-api; CHANGELOG
- tests: manifest validity, id parity, distinct cache roots, parsing
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
End-to-end measurement for the Korean set (Linux x64, 12-thread laptop CPU, release build with Input: a Korean government legal-interpretation PDF (text-based) rasterised to a 150 dpi greyscale image-only PDF, 3 pages, classified
Clean text PDFs are unaffected (no renderer, model, or ORT initialisation happens before routing). |
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/vision/contracts.rs">
<violation number="1" location="src/vision/contracts.rs:95">
P2: Adding this field breaks downstream `OcrOptions { ... }` struct literals because `OcrOptions` is public and not `#[non_exhaustive]`. Preserve source compatibility with a separate versioned options type/API, or treat this as a semver-breaking change and release it under the appropriate major-version policy.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
| /// Whether a missing pinned artifact may be downloaded. | ||
| pub model_downloads: ModelDownloadPolicy, | ||
| /// Which pinned model set the engine loads. | ||
| pub model_set: OcrModelSet, |
There was a problem hiding this comment.
P2: Adding this field breaks downstream OcrOptions { ... } struct literals because OcrOptions is public and not #[non_exhaustive]. Preserve source compatibility with a separate versioned options type/API, or treat this as a semver-breaking change and release it under the appropriate major-version policy.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/vision/contracts.rs, line 95:
<comment>Adding this field breaks downstream `OcrOptions { ... }` struct literals because `OcrOptions` is public and not `#[non_exhaustive]`. Preserve source compatibility with a separate versioned options type/API, or treat this as a semver-breaking change and release it under the appropriate major-version policy.</comment>
<file context>
@@ -40,6 +91,8 @@ pub struct OcrOptions {
/// Whether a missing pinned artifact may be downloaded.
pub model_downloads: ModelDownloadPolicy,
+ /// Which pinned model set the engine loads.
+ pub model_set: OcrModelSet,
}
</file context>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Re the automated note on
If you would rather gate this behind |
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Shadow auto-approve: would not auto-approve. Auto-approval blocked by 1 unresolved issue from previous reviews.
Re-trigger cubic
Summary
Adds
OcrModelSetso the selective-OCR path can load a different pinned, checksum-verified model set without changing anything else in the pipeline. The default set (PpOcrV6Small) and all existing behavior are unchanged; the newPpOcrV5Koreanset makes Hangul readable.Motivation: the PP-OCRv6 Small dictionary contains no Hangul at all (18,709 entries, 0 in U+AC00–U+D7A3), so every Korean scanned page currently comes back empty even though the routing, rendering, fusion and Markdown assembly all work. The PP-OCRv5 Korean recogniser published with
oar-ocr(already the crate's OCR backend) covers all 11,172 Hangul syllables plus Latin letters and digits, and pairs with the script-agnostic PP-OCRv5 mobile detector. Together the set is ~18 MB, smaller than the default.What changed
vision::OcrModelSet(PpOcrV6Smalldefault,PpOcrV5Korean) with stable identifiers, a lenientparse, andDisplay.#[non_exhaustive]so more sets can follow.OcrOptions::model_set(...)/OcrOptions.model_set.Defaultstill selects PP-OCRv6 Small.vision::PP_OCR_V5_KOREANmanifest pinned to theoar-ocrv0.3.0 release files (SHA-256 and exact sizes), andOcrModelSet::manifest().cached_ocr_enginenow resolves, downloads, and caches by the selected manifest. The engine cache key already carried manifest id/revision/digests, so switching sets replaces the loaded sessions instead of mixing artifacts; each set also lives under its own<id>/<revision>cache directory.pdf2md --ocr-model-set pp-ocrv5-korean(listed with the other OCR-only options; invalid values print the accepted identifiers).docs/ocr-runtime.md"Model sets" table and examples,docs/rust-api.md, CHANGELOG.Python and Node bindings are untouched in this PR (they keep the default set); happy to add a
model_setoption to both in a follow-up if you want parity in the same release.Verification
cargo fmt,cargo clippy -- -D warnings,cargo clippy --features ocr -- -D warnings,cargo test,cargo test --features ocr --lib vision::on the pinned 1.98.0 toolchain.OcrModelSetresolves to a manifest whoseidmatches; sets use distinct cache roots; identifier parsing round-trips and rejects unknown values;OcrOptionsdefault is unchanged.native-v7988, ONNX Runtime 1.27.0, CPU): a Korean government PDF rasterised to a 150 dpi image-only PDF (3 pages, classifiedscanned) processed with--ocr auto --ocr-model-set pp-ocrv5-korean --ocr-offline --ocr-model-dir …. Results are in the comment below.Notes for reviewers
oar-ocrv0.3.0 GitHub release (pp-ocrv5_mobile_det.onnx4,826,518 B,korean_pp-ocrv5_mobile_rec.onnx13,446,374 B,ppocrv5_korean_dict.txt47,451 B).Summary by cubic
Adds
OcrModelSetso the selective-OCR path can load a different pinned, checksum-verified model set. The defaultPpOcrV6Smallset is unchanged, and the newPpOcrV5Koreanset makes Hangul readable — Korean scanned pages previously came back empty because the default dictionary has no Hangul.PpOcrV5Koreanpairs the script-agnostic PP-OCRv5 mobile detector with the Korean recogniser and dictionary (~18 MB total).OcrOptions::model_set(...)andpdf2md --ocr-model-set pp-ocrv5-koreanselect the set; the engine cache is keyed by the selected set, so switching sets never mixes artifacts.OcrOptionsgained a publicmodel_setfield, so struct literals that spell out every field need the new field.Written for commit 76cdc11. Summary will update on new commits.