0. Usage
Requirements: vllm (verified on 0.28.0), pillow. The remote code from the base model is included
(trust_remote_code=True). Decoding is greedy with prompt OCR:; these settings are the ones measured below.
python inference.py line1.png line2.png --model ThakiCloud/ThakiOCR-JA-v1 --kind line --orientation upright
from huggingface_hub import snapshot_downloadfrom inference import ThakiOCRJA # inference.py from this repository model_dir = snapshot_download("ThakiCloud/ThakiOCR-JA-v1")ocr = ThakiOCRJA(model_dir)res = ocr.recognize(["line.png"], kind="line", orientation="upright")print(res[0]["raw_text"]) # model output, never modifiedres = ocr.recognize(["line.png"], kind="line", orientation="upright", normalize_mode="modern_ja")print(res[0]["raw_text"], res[0]["text"]) # text = raw_text with 齡→齢 and ·→・ only
Orientation contract (caller-supplied)
The model does not detect orientation. The caller states it:
Table with columns: orientation, Meaning, What the script doesorientation | Meaning | What the script does |
|---|
upright (default) | the line is in reading orientation | nothing |
rot_ccw90 | a vertical line stored rotated 90° counter-clockwise | rotates 90° clockwise before OCR |
unknown | no metadata | nothing, and the result is flagged orientation_unverified: true — no accuracy is claimed |
Output fields and optional normalization
Every result has raw_text (the model's greedy output) and text. With the default normalize_mode="raw"
they are identical. normalize_mode="modern_ja" maps exactly two characters in text:
齡 (U+9F61) → 齢 (U+9F62) and · (U+00B7) → ・ (U+30FB). raw_text is never changed. The default is
raw because in historical documents and proper nouns the variant form can be the correct transcription.
1. What is supported and what is not claimed
Table | |
|---|
| ✅ Supported | Line images from horizontal printed Japanese documents; orientation supplied by the caller (upright / rot_ccw90) |
| ⚠️ Unverified | Images without orientation metadata (unknown) — no performance guarantee |
| ❌ Not claimed | Full vertical-page Japanese OCR · automatic orientation detection · Korean or English OCR · document layout parsing · exact digit/symbol accuracy · general superiority over PaddleOCR-VL-1.6 · production readiness |
2. Main evaluation — gov_ja_v2 (Japanese government white papers)
2,000 text lines from 30 PDFs of 5 public sources (Cabinet Office ageing-society and disability white papers,
Ministry of the Environment, MEXT science & technology, MIC information & communications white papers, FY2024
editions); 931 lines contain digits. Character error rate after NFKC with whitespace removed. Digit precision,
recall and F1 match digit spans (runs of digits; 1,463 in the ground truth); digit hallucination is the share of the
1,069 digit-free lines where the model output any digit. 95% CIs come from a paired cluster bootstrap over the 30 PDFs
(B = 1000, seed 20261118). All three models use the same decoding.
Table with columns: Model, CER, Digit F1, Digit precision, Digit recall, Digit hallucination (line rate)| Model | CER | Digit F1 | Digit precision | Digit recall | Digit hallucination (line rate) |
|---|
| PaddleOCR-VL-1.6 (base) | 0.0118 | 0.9956 | 0.9925 | 0.9986 | 0.0075 |
| ThakiOCR-JA-v1 | 0.0094 | 0.9973 | 0.9973 | 0.9973 | 0.0009 |
| sibling B (rotation-augmented SFT, not released) | 0.0148 | 0.9908 | 0.9884 | 0.9932 | 0.0009 |
Table with columns: Comparison (Δ = ours − other), CER Δ [95% CI], Digit F1 Δ [95% CI]| Comparison (Δ = ours − other) | CER Δ [95% CI] | Digit F1 Δ [95% CI] |
|---|
| vs base | −0.0024 [−0.0060, +0.0008] | +0.0017 [−0.0025, +0.0068] |
| vs sibling B | −0.0054 [−0.0110, −0.0016] | |
- Non-inferiority vs base: PASS on CER (upper CI bound below +0.01), digit F1 (lower bound above −0.02) and
digit hallucination rate (upper bound below +0.01); margins were fixed before evaluation.
Superiority vs base: not established — every CI includes 0.
- These are observations on one evaluation set (5 sources, 30 PDFs) with repaired ground truth (§3). It is
a repaired evaluation, not an untouched independent test.
- The decision rules (gates, margins, bootstrap) were registered before the numbers were computed and were not
changed afterwards.
Per source (CER; Δ = ours − base, CI over PDFs within the source)
Table with columns: Source, Lines, Base, Ours, Δ [95% CI], Digit F1 base → ours| Source | Lines | Base | Ours | Δ [95% CI] | Digit F1 base → ours |
|---|
| MEXT science & technology | 306 | 0.0188 | 0.0067 | −0.0121 [−0.0243, +0.0009] | 0.9712 → 0.9926 |
| MIC information & communications | 404 | 0.0157 | 0.0099 | −0.0058 [−0.0084, −0.0035] | 1.0000 → 0.9944 |
| Ministry of the Environment | 454 | 0.0096 | 0.0089 | −0.0007 [−0.0034, +0.0013] | 1.0000 → 1.0000 |
| Cabinet Office, disability | 403 | 0.0122 | 0.0105 | −0.0017 [−0.0122, +0.0058] | 0.9983 → 0.9983 |
| Cabinet Office, ageing society | 433 | 0.0042 | 0.0100 | +0.0058 [+0.0020, +0.0099] | 1.0000 → 1.0000 |
The ageing-society source is a confirmed regression (the CI excludes 0). In the MIC source CER improves
but digit F1 drops slightly (0.9944 vs 1.0000).
In-domain sets (same distribution as the training data — not evidence of generalization)
Table with columns: Set, Lines, Base CER, Ours CER| Set | Lines | Base CER | Ours CER |
|---|
| NDL part 2 (all part-2 books excluded from training) | 1,500 | 0.1194 | 0.0460 |
| JSSODa test | 400 | 0.0495 | 0.0061 |
3. Ground-truth repair history
The ground truth comes from the PDF text layer. A pixel-level audit (no model outputs used) first found that
5.6% of lines did not match their crop — mostly table rules, shaded boxes and neighbouring-line bleed inside the
crop, plus footnote marks (※5, *23) present in the image but missing from the text. The audit failed its own
pre-set threshold, so the first evaluation was declared inconclusive.
The repair was rule-based and blind to model names and predictions: recover glyphs the font's ToUnicode map
dropped (2 lines), merge short footnote marks that sit on the same line (27), and redact vector decoration or
neighbouring glyph pixels outside the line's own characters (90; a guard aborts the edit if a real glyph would be
removed). Only characters actually present in the image enter the ground truth. No line was removed or
replaced; the 2,000 lines and the source mix are unchanged; 2 lines whose text is covered by later fills were
kept with their original label and counted as audit failures.
Table with columns: Audit (same thresholds), Before, After| Audit (same thresholds) | Before | After |
|---|
| Lines passing | 0.944 | 0.979 (pass threshold 0.95) |
| Worst source | 0.871 | 0.943 (threshold 0.90) |
| Failing lines | 112 | 42 = 40 extra-ink + 2 covered-text (no overlap) |
Repair changed 93 images and 29 ground-truth strings; 43 candidate image edits were aborted by the guard and left
as they were. Effect on scores (repaired vs original ground truth; changed images re-run through each model):
CER base −0.0002, ours −0.0017, sibling B +0.0005, every CI includes 0. Digit F1 rose by about +0.003 for all three
models (CIs exclude 0), so the repair moved digit F1 equally and did not change the comparisons.
4. Known limitations — read this
- Variant glyph 齡 for 齢. In the ageing-society source the model wrote 齡 for 37 of the 42 occurrences of
齢 (50 times across all sources; the base model never did). It also writes the middle dot ・ (U+30FB) as
· (U+00B7) (46 times; base 11). NFKC does not unify either pair. These substitutions account for the
ageing-society regression above; the sibling B model shows the same pattern, so it comes from the
fine-tuning, not from the ground-truth repair. A plausible but unverified cause is the classical-book
portion of the training data, where old character forms are common.
- The optional
modern_ja normalization is a workaround, not a fix. It is off by default. Measured
separately on the same evaluation set (report-only, not part of the registered result): see §5. Because
the two mappings were chosen after seeing errors on this set, that measurement is optimistic and does not
show the regression is solved on other documents.
- Orientation must be supplied. On a mixed-orientation tategaki line set, feeding rotated vertical lines
as-is raises CER sharply (0.176 vs 0.071 with
rot_ccw90). The model has no orientation detector.
- Line images only. Page-level parsing, multi-column reading order and vertical full pages are not
claimed.
- Digits and symbols are not guaranteed. Digit F1 is high on this set but not perfect, and one source
shows a small digit regression.
- Not multilingual. Korean and English were not training targets. On our small Korean and English
control line sets the base model already has high CER under this prompt and crop setup, and this model is no
better in a way we can claim. Do not use it for those languages.
5. Optional normalization — separate measurement (report-only)
modern_ja applied to our predictions only, base and sibling B left raw, same set and bootstrap:
Table with columns: CER, Δ vs base [95% CI] | CER | Δ vs base [95% CI] |
|---|
| ThakiOCR-JA-v1, raw (registered result) | 0.0094 | −0.0024 [−0.0060, +0.0008] |
ThakiOCR-JA-v1 + modern_ja | 0.0075 | −0.0043 [−0.0077, −0.0015] |
Ageing-society source with modern_ja: CER 0.0035 vs base 0.0042, Δ −0.0008 [−0.0040, +0.0022]. 189 of 2,000
predicted lines change. Digit F1 is unchanged (0.9973). If the same mapping is also applied to the base and
sibling B outputs, the base CER becomes 0.0115 and the overall Δ is −0.0040 [−0.0073, −0.0013].
This is a post-hoc measurement on the same set that revealed the substitutions, so it is optimistic. It is not a
registered result, it does not replace §2, and it does not show the regression is solved on other documents.
6. Training data
- NDL 古典籍 OCR dataset, part 1 line data (National Diet Library, Public Domain Mark) — 500 pages sampled
round-robin by book.
- JSSODa train shard 0 (
llm-jp/JSSODa, revision cbe246e8, CC BY 4.0; arXiv:2511.15059).
- After exclusions: 46,102 training lines (NDL 41,828 from 465 books, JSSODa 4,274).
- Evaluation pages, test splits and near-duplicates (text and perceptual hash) were excluded before training.
- No AI Hub data and no private data were used. No dataset, PDF or evaluation crop is distributed in this
repository.
7. Reproducibility and files
Table | |
|---|
| Base | PaddlePaddle/PaddleOCR-VL-1.6 @ 132c45f52c0a26ed5a6b2f6bd8e3985794cc27dd |
| Adapter (merged) | LoRA r 16, α 32, 290 modules, step 600, sha256 e17c8f0cdeb2df562337d14bb5875f99e241e11b902c7d570e6ef451ef7688fe |
model.safetensors | 1,917,255,968 bytes, sha256 5927af2cce698f7ef8fb12d09302357beaf61835c852f55b3f78759018fc5d8c |
| Engine | vLLM 0.28.0, greedy, prompt OCR:, max tokens 256 (line) / 4096 (page), max pixels 1280·28·28 |
| Package check | this merged package reproduced the pre-packaging predictions on a 1,500-line set in both orientations (row match 1.000, ΔCER 0) |
THAKI_MANIFEST.json lists every file's sha256. Files other than model.safetensors, README.md,
MODEL_CARD.ko.md, inference.py, NOTICE and THAKI_MANIFEST.json are the base model's files unchanged.
8. License
Apache-2.0, the same as the base model. See LICENSE and NOTICE (changes from the base model and data
attribution).