ThakiOCR-KOENJA-G2M-v1
This is a Korean, English and Japanese text-line recognizer with 10.17 M parameters, trained with CTC loss, that runs on CPU. It continues training from ThakiOCR-KOEN-G2M-R3 and has one shared output head of 18,133 characters: the 14,250 R3 Korean/English characters in their original order, plus 3,883 characters taken from the Japanese training labels (mostly kanji, also kana and full-width punctuation). The model reads one cropped, horizontal text line and returns its transcription. It does not find text on a page, so pair it with a line detector or a layout model.
Korean card: MODEL_CARD.ko.md carries the same facts in Korean.
What this release shows. On an untouched external test set of modern Japanese government PDFs from the Japan Meteorological Agency (JMA; 718 lines, 40 documents), CER after NFKC is 0.87%. A control run with the same start, steps and seed but without the new modern Japanese training lines reached 1.11%. The difference is −0.24 pp, with a document-level 95% CI of [−0.36, −0.10]. Historical Japanese, Korean and English stayed within limits fixed before training.
What it does not show. It is not better than PP-OCRv6. Their difference on the same 718 lines is not statistically significant (CI includes 0), and equivalence was not shown either. Printed full-width digits (0–9) are never output in their original form, because the character set has none. Measured with one seed, on born-digital PDFs only; scanned documents are untested.
Status: research preview, not a product release. Production use is NO-GO. Training of this checkpoint is frozen.
Quick start
pip install torch numpy pillow safetensors
python inference.py line.png # one or more line images
python inference.py --demo # renders an English line and reads it back
from inference import ThakiOCR
ocr = ThakiOCR(".", device="cpu")
print(ocr.recognize(["line1.png", "line2.png"]))
inference.py is self-contained (torch, numpy, Pillow, safetensors). Its code is the same as in the G2M-R2 and G2M-R3 releases, except the model name in the docstring. config.json sets the larger output head and vocab.json lists the 18,133 characters.
Reproduction on CPU. Before upload, the released files were run on CPU over the 718 test lines (stored 48-px grayscale images, 64 lines per batch, stored order). All 718 predictions matched the frozen evaluation predictions behind the numbers below, string for string. recognize() with its default batch of 128 gave the same 718 strings.
Files
| File | Content |
|---|---|
model.safetensors | fp32 weights (state_dict only, no optimizer state), byte-identical to the evaluated checkpoint (SHA-256 b0d4cb68…3926ff) |
config.json | architecture, preprocessing and decoding settings, provenance hashes |
vocab.json | 18,133 characters; CTC index i maps to chars[i-1], index 0 is blank |
inference.py | standalone model code, preprocessing, greedy CTC decoding, CLI |
LICENSE | Apache-2.0 (code and weights) |
NOTICE | training data attribution (CC BY 4.0, Public Domain Mark, PDL 1.0, SIL OFL 1.1 fonts, AI Hub) and what is not included |
Results: modern Japanese (final test set)
Test set. 718 horizontal text lines from 40 PDFs published by the Japan Meteorological Agency: pamphlets, technical reviews, numerical-forecast explainers and disaster weather reports. The source was frozen before training and never used for training, development or checkpoint choice in this model line. Training used white papers of other ministries, so the test set comes from a different agency, but it has the same medium (born-digital PDF rendered at 200 dpi) and era. Ground truth comes from the PDF text layer. A prediction-blind audit of 60 sampled lines found 2 defects; those 2 lines were removed for every model before prediction, and about 3% residual label noise likely remains.
Scoring. CER = total edit distance / total reference characters, after Unicode NFKC and removal of all whitespace. Raw CER uses NFC instead of NFKC, so it counts full-width versus half-width forms as errors. Greedy decoding. The G2M models and PP-OCRv6 ran on CPU in fp32; ThakiOCR-JA-v1 ran on a GPU under vLLM (greedy, prompt OCR:), and its predictions were matched to the 718 lines by line ID. Every model read the same stored 48-px grayscale line image. That image is this model's own preprocessing; PP-OCRv6 and ThakiOCR-JA-v1 normally see the original color crop at a larger size, so this setup may put them at a disadvantage. Confidence intervals: paired bootstrap over documents, 1,000 resamples.
| Model | What it is | CER (NFKC) | Raw CER (NFC) |
|---|---|---|---|
| ThakiOCR-KOENJA-G2M-v1 | this release | 0.87% | 3.28% |
| control (not released) | same start, steps and seed, no modern Japanese lines | 1.11% | 5.09% |
| start checkpoint (not released) | the checkpoint both runs continued from | 1.14% | 5.10% |
| PP-OCRv6 small rec (ONNX) | PaddlePaddle/PP-OCRv6_small_rec_onnx @ b8f84f0b, run by us | 0.81% | 3.02% |
| ThakiOCR-JA-v1 | our earlier Japanese VLM-based model | 1.46% | 4.75% |
| Paired difference (CER, NFKC) | Δ | 95% CI | Reading |
|---|---|---|---|
| this release − control | −0.24 pp | [−0.36, −0.10] | better (pre-registered primary test) |
| this release − start checkpoint | −0.27 pp | [−0.38, −0.15] | better |
| this release − PP-OCRv6 | +0.06 pp | [−0.17, +0.34] | no significant difference; equivalence not shown |
| this release − ThakiOCR-JA-v1 | −0.59 pp | [−1.53, +0.13] | no significant difference |
- By genre: the gain comes from the 641 general JMA lines (−0.21 pp, CI [−0.35, −0.08]). On the 77 disaster-report lines the difference is −0.55 pp but the CI [−1.43, +0.08] includes 0.
- Digit F1 on this set: 0.984 (start checkpoint 0.981).
- Digits invented on the 388 lines that contain no digit: 0 lines for this release, 2 lines for the start checkpoint and for the control, 1 line for PP-OCRv6.
- PP-OCRv6 and ThakiOCR-JA-v1 were run once by us with the settings above. We do not copy numbers from other reports.
Character forms (descriptive, measured after the fact)
These counts were taken after the verdict, by aligning raw predictions with the reference on the same 718 lines. They were not a release gate.
| Character type | In reference | This release | Control | PP-OCRv6 |
|---|---|---|---|---|
| small っ | 64 | 64 | 64 | 59 (5 read as つ) |
| long-vowel mark ー | 150 | 149 | 135 | 145 |
| Latin O (not digit 0) | 51 | 46 | 44 | 51 |
| circled numbers ①… | 5 | 3 | 0 | 4 |
| full-width digits 0–9, exact form | 97 | 0 | 0 | 6 |
| symbols and punctuation, exact form | 1,492 | 1,123 | 834 | 1,213 |
- Full-width digits. The 18,133-character vocabulary has no full-width digits, so this model writes all 97 as ASCII digits. After NFKC all 97 are correct, which is why NFKC CER and digit F1 do not show the loss. If you need the printed form (for example for exact text search or layout reproduction), this model cannot give it.
- Most of the raw-CER gain over the control (5.09% → 3.28%) comes from full-width punctuation and symbols now written in their printed form.
Retention checks (limits fixed before training)
| Check | Set | This release | Limit | Reference |
|---|---|---|---|---|
| Historical Japanese | 1,125 lines from 90 NDL public-domain books held out of training | 14.80% | ≤ 16.14% | start checkpoint 15.14% |
| Historical digit F1 | same set | 0.711 | drop ≤ 0.02 vs start | start 0.687 |
| Korean | 5,000 NVIDIA synthetic Korean validation lines | 5.64% | ≤ 5.93% | G2M-R3 5.43% |
| English | 5,000 NVIDIA synthetic English validation lines | 4.49% | ≤ 5.14% | G2M-R3 4.64% |
- Korean and English use the definition of the R3 card (NFC, no-break space to space, whitespace kept). Korean is 0.21 pp worse than G2M-R3, within the limit but a real cost. The R3 values come from an earlier job on the same 5,000 rows with the same scoring code.
- These are synthetic sets. Real Korean documents were not re-measured for this release.
- On the historical set, PP-OCRv6 scored 17.43%.
How it was trained
- Lineage, all ThakiCloud weights: G2M-Preview (random init) → G2M-R2 → G2M-R3 → Japanese head extension and 13,000 steps → +6,000 steps with historical NDL lines → +6,000 steps with modern Japanese lines (this release). Only the last step is described below.
- Head extension: 3,883 characters from the Japanese training labels were added to the R3 head. Existing rows were kept and the new rows started suppressed. R3's 14,250 characters keep their indices.
- Last stage: 6,000 steps, batch 128, AdamW (head 5e-4, backbone 1e-4, weight decay 0.02), 500 warmup steps, then constant to step 1,000, then cosine; seed 42; one B200 GPU. Final step kept; no checkpoint was chosen on any evaluation.
- Mix by positions drawn: NVIDIA synthetic Japanese 18%, modern Japanese government lines 18%, NDL historical lines 18%, other real Japanese lines (NDL classical books, JSSODa) 6%, NVIDIA synthetic Korean 20%, NVIDIA synthetic English 20%. The control run is byte-identical except that the modern 18% was NVIDIA synthetic Japanese.
- The modern lines: 7,596 lines from 90 PDFs (86 Ministry of Health, Labour and Welfare, 3 Ministry of Agriculture, Forestry and Fisheries, 1 Forestry Agency), cut from the PDF text layer and rendered at 200 dpi. Each line was seen about 18 times. Lines with characters outside the fixed 18,133-character set (full-width digits and Latin, some symbols) were dropped, not folded, so the training text has ASCII digits only.
- No augmentation, no new loss, no quantization. Both runs together used 0.51 GPU-hours.
- No training data is distributed. This repository holds weights and code only.
Known limitations
- One seed. Run-to-run variance was not measured.
- Born-digital only. Training and test images are rendered PDFs. Scanned, photographed, handwritten or low-contrast text is untested.
- Narrow genre. The new Japanese training lines are government white papers; the test set is the same era and medium from another agency.
- Repetition. Each modern training line was seen about 18 times.
- Full-width digits are lost (see above). Do not apply NFKC to whole strings if you need to keep other full-width forms.
- Label noise. About 3% of test labels may be wrong; it is the same for every model.
- Historical Japanese from new sources. An earlier external test on historical Japanese from sources outside our training archive did not show a reliable gain. The historical number above is a retention check on a held-out part of the same archive, not evidence of general historical-document ability.
- Horizontal lines only. Vertical Japanese text is out of scope. Lines wider than 2,048 px after resizing to height 48 are rejected.
- Line input only. A page or multi-line block produces garbage.
- Batch effects. White padding at line ends is visible to the depthwise convolution, so output depends on the other lines in a batch. On the 718 test lines, one line per call (
batch_size=1) changed 22 lines and gave 0.97% NFKC CER instead of 0.87%. All numbers in this card come from batched inference (64 lines per batch). - Critical fields. Do not process amounts, account or ID numbers, dates or contract terms automatically. Keep a human review step.
Model
- Input: one grayscale text-line image. EXIF transpose, resize to height 48 keeping the aspect ratio (bilinear), width
max(8, round(w*48/h)), pixels scaled to [-1, 1] (x/127.5 - 1). A batch is right-padded with white to a multiple of 16. - Encoder: convolutional stem (160 channels), mean pooling over height, projection to 320 dims, six blocks of depthwise 1-D convolution (kernel 5) with a gated feed-forward, LayerNorm. Same as G2M-R3.
- Head: dense linear layer to 18,134 classes (18,133 characters + blank). One Hangul syllable or one kana/kanji = one class.
- Decoding: greedy CTC (blank 0, merge repeats). No language model.
- Parameters: 10,172,694.
- Label normalization in training: Unicode NFC. NFKC is not applied.
Intended use
Research on Korean, English and Japanese line recognition inside a larger document pipeline. Not for unattended reading of financial, legal or identity documents.
License and attribution
Code and weights: Apache-2.0 (see LICENSE). Training data attribution, in short (details in NOTICE):
- NVIDIA OCR-Synthetic-Multilingual-v1, Korean, English and Japanese training shards (CC BY 4.0).
- AI Hub (AI-Hub) — OCR data (public) (71299) and AI Hub (AI-Hub) — Financial-domain document OCR (632), Training splits, used in the earlier G2M rounds this model continues from, under the AI Hub usage policy. AI Hub data is not redistributed and may not be redistributed; this repository contains no AI Hub data.
- National Diet Library (NDL) PDM OCR dataset parts 1 and 2 and NDL classical-book OCR dataset part 1 (Public Domain Mark).
- JSSODa (llm-jp/JSSODa, CC BY 4.0).
- 出典:厚生労働省、農林水産省、林野庁 ウェブサイト掲載の白書・報告書 PDF (公共データ利用規約 第1.0版, PDL 1.0). ThakiCloud cut text lines from these PDFs and rendered them as images to train this model. The publications themselves are not included.
- ThakiCloud synthetic symbol lines rendered with SIL OFL 1.1 fonts (earlier rounds).
The JMA test PDFs (気象庁, PDL 1.0) were used for evaluation only.