ThakiOCR-KOEN-G2M-R2
A Korean/English text-line recognizer (8.93 M parameters, CTC). It is the second round of ThakiOCR-KOEN-G2M-Preview: the same network, trained 80,000 more steps from the Preview weights. It reads one cropped text line and returns its transcription. It does not find text on a page; pair it with a line detector or layout model.
Korean card: MODEL_CARD.ko.md carries the same facts in Korean.
What changed versus G2M-Preview. Character error rate (CER) went down on all seven of our development sets. Most of the gain is on synthetic Korean and English lines (−1.02 and −0.90 percentage points). On real scanned documents the gain is small: −0.05 points on text lines and −0.33 points on words, which we do not claim to be significant.
Status: research preview, not a product release. Production use is NO-GO. The Preview repository is kept unchanged so both versions can be compared.
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) and identical in code to the Preview release; only the weights differ. The vendored network was checked against the training code on these weights before upload (maximum logit difference below 1e-4, identical argmax).
Files
| File | Content |
|---|---|
model.safetensors |
fp32 weights (state_dict only, no optimizer state) |
config.json |
architecture, preprocessing and decoding settings, provenance hashes |
vocab.json |
14,250 characters, byte-identical to the Preview vocabulary; 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 |
data attribution (CC BY 4.0, SIL OFL 1.1 fonts, AI Hub) and what is not included |
Results versus G2M-Preview
Both columns were measured in the same job, on the same rows, with the same code: the Preview weights were scored before training started, the R2 weights after it ended. CER after Unicode NFC, greedy CTC decoding, single run, single seed. Lower is better.
| Dev set | What it is | Rows | G2M-Preview | G2M-R2 | Change (pp) |
|---|---|---|---|---|---|
| ko_val | NVIDIA synthetic Korean lines, validation split | 5,000 | 6.38% | 5.36% | −1.02 |
| en_val | NVIDIA synthetic English lines, validation split | 5,000 | 5.49% | 4.59% | −0.90 |
| gold_dev | AI Hub 71299 official Validation split, word and line crops (never trained on) | 5,000 | 4.34% | 4.17% | −0.16 |
| real_ival_word | AI Hub 71299, internal validation words held out of the Training split | 5,000 | 8.87% | 8.53% | −0.33 |
| real_ival_line | AI Hub 71299, internal validation lines held out of the Training split | 2,895 | 8.43% | 8.37% | −0.05 |
| hold_line | AI Hub 71299, lines from volumes held out of training | 4,000 | 4.47% | 4.46% | −0.01 |
| a1_dev | ThakiCloud synthetic symbol lines (currency, dates, circled and masked digits) | 5,229 | 0.36% | 0.28% | −0.09 |
CER on subsets of the same rows, split by the reference text. "Short" means at most three non-space characters; "digits/symbols" means the text contains a digit or a symbol; "plain" (used below) means neither.
| Dev set | Short: Preview | Short: R2 | Digits/symbols: Preview | Digits/symbols: R2 |
|---|---|---|---|---|
| ko_val | 12.54% | 12.01% | 6.99% | 5.83% |
| en_val | 7.42% | 5.66% | 6.07% | 5.10% |
| gold_dev | 3.94% | 3.75% | 6.03% | 5.82% |
| real_ival_word | 8.68% | 8.72% | 10.38% | 9.98% |
| real_ival_line | 32.76% (49 rows) | 33.91% | 7.79% | 7.72% |
| hold_line | 30.99% (38 rows) | 30.99% | 4.53% | 4.52% |
These are development sets. They were used to choose between two R2 candidates, so they are not independent test sets. The independent sets reported on the Preview card (symbol test and the 526-crop real holdout) were not re-run for this release.
How R2 was trained
- Start: the G2M-Preview weights (40,000 steps). Weights only: the optimizer was re-created and the schedule restarted.
- Training: 80,000 added steps (120,000 cumulative), batch 128, AdamW with weight decay 0.02, 1,000 warmup steps then cosine decay, peak learning rate 2e-4, seed 42, one B200 GPU, 4.45 GPU-hours.
- Data mix by samples drawn (10.24 M in total): NVIDIA synthetic Korean lines 35%, NVIDIA synthetic English lines 15%, AI Hub 71299 Training text lines 31.5%, AI Hub 71299 Training words 3.5%, ThakiCloud synthetic symbol lines 15%. The real-line pool has 28,061 unique crops, so each real line was seen about 115 times.
- No training image is an evaluation image (checked by image SHA-256; zero overlap).
- Checkpoint: the final step. A second candidate (R2B), which oversampled short and hard rows three times, scored better on synthetic and digit/symbol rows but got worse on plain real text lines (9.80% to 10.18% CER on real_ival_line plain rows). A rule fixed before training says to reject a candidate that regresses general real text, so R2B was not selected and is not published.
- No training data is distributed. AI Hub originals and derived crops stay on ThakiCloud domestic storage; this repository holds weights and code only.
Known limitations
- Small gain on real images. On real scanned lines CER moved from 8.43% to 8.37%. Training three times longer on the same real lines did not move real-image accuracy much; more varied real training images are likely needed.
- Short real text got slightly worse. On real lines of three non-space characters or fewer CER rose from 32.76% to 33.91%, and on short real words from 8.68% to 8.72%. Those subsets are small (49 lines), but very short fields are where this model is weakest.
- Dates. On real development lines date-token exact match is 44% (real_ival_line) to 55% (hold_line). Dates written with inner spaces (
YYYY. M.DD) remain a known weakness inherited from the Preview. ₩versus₩. The two won signs look almost the same in the fonts we used, and the Preview confused them. This was not re-measured for R2. If you need the exact code point, do not rely on this model; if you only need the currency meaning, map both to KRW in post-processing (do not apply NFKC to whole strings).- Critical fields in financial and contract documents. Do not use this model to process critical fields (amounts, account or ID numbers, dates, contract terms) automatically. Keep a human review step.
- Not independently tested. All numbers above come from development sets that also guided the R2A/R2B choice.
- Domain. Printed public documents and synthetic renderings. Photographed, handwritten, low-contrast or stylized text is out of scope.
- Line input only. A whole page or a multi-line block produces garbage. Lines wider than 2048 px after resizing are rejected.
- Batch effects. White padding at line ends is visible to the depthwise convolution, so output can change slightly with the other lines in a batch.
- Single seed. Run-to-run variance was not measured.
- No training data in this repository. No AI Hub images, crops, labels or caches are included.
Model
Same architecture and preprocessing as G2M-Preview:
- 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.
- Head: dense linear layer to 14,251 classes (14,250 characters + blank); one Hangul syllable = one class.
- Decoding: greedy CTC. No language model.
- Parameters: 8,926,251.
- Label normalization: Unicode NFC and no-break space to space. NFKC is not applied.
Intended use
Research on Korean/English 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). Data attribution: NVIDIA OCR-Synthetic-Multilingual-v1 (CC BY 4.0); fonts under SIL OFL 1.1 for synthetic rendering; AI Hub (AI-Hub) dataset 71299 (Training split) used for training under the AI Hub usage policy, not redistributed. Details in NOTICE.
- Downloads last month
- 31