ThakiOCR-KOEN-G2M-Preview
A Korean/English text-line recognizer (8.93 M parameters, CTC, trained from scratch) released as a research preview. 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.
Newer version: ThakiOCR-KOEN-G2M-R2 continues training from these weights (80,000 more steps) and has lower CER on all seven of our development sets. This repository is kept unchanged.
Status: research preview, not a product release. Under our own preregistered gates this model was judged A1_GEN2_NO_GO: it passed four of five gates and failed gate I4 (date tokens). Production use is NO-GO. We publish it so the work can be inspected and reused for research, not because it met our bar. We make no claim of state-of-the-art accuracy.
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). It holds a vendored copy of the network, the preprocessing and the greedy CTC decoder. The vendored network was checked against the training code on the released 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; 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 |
Model
- Input: one grayscale text-line image.
- Preprocessing: EXIF transpose, grayscale, resize to height 48 keeping the aspect ratio (bilinear), width
max(8, round(w*48/h)); lines wider than 2048 px after resizing are rejected rather than squeezed. Pixels are 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; stride stages 2, 2, then 2 in height only), mean pooling over height, projection to 320 dims, six blocks of depthwise 1-D convolution (kernel 5) with a gated feed-forward, LayerNorm. The
headsfield inconfig.jsonis unused by this local-mixing variant. - Head: dense linear layer to 14,251 classes (14,250 characters + blank), one class per character (one Hangul syllable = one class).
- Output stride: 4 pixels of resized width per CTC frame.
- Decoding: greedy CTC (argmax, merge repeats, drop blanks). No language model.
- Parameters: 8,926,251 (head 4,574,571, encoder 4,351,680).
- Label normalization used in training and scoring: Unicode NFC and no-break space to space. NFKC is not applied, so
₩(U+FFE6) and₩(U+20A9) stay different characters.
Training
- Data, mixed by fixed ratios over 40,000 steps of batch 128 (5.12 M samples):
- text-line crops rendered from NVIDIA OCR-Synthetic-Multilingual-v1 (CC BY 4.0), Korean and English training shards;
- text-line and word crops from the official Training split of AI Hub dataset 71299 (Korean public documents). The AI Hub Validation split was not used for training;
- synthetic symbol lines generated by ThakiCloud (currency signs, dates, circled numbers, masked digits), rendered with fonts under the SIL Open Font License 1.1.
- Vocabulary: the 14,152-character set of ThakiOCR-KOEN-V1-Dense, plus
₩and¥, plus 96 characters that occur at least three times in the training labels. - Recipe: AdamW, lr 5e-4, 2,000 warmup steps, seed 42, one B200 GPU, 2.22 GPU-hours. Random initialization (not a fine-tune).
- Checkpoint: the fixed final step. Between two sizes trained the same way, this one was picked by a rule fixed in advance (lower mean development CER, ties go to the smaller model).
- No training data is distributed. AI Hub originals and derived crops stay on ThakiCloud domestic storage; this repository holds weights and code only.
Evaluation
Each independent set was opened exactly once, after training and selection, under preregistered gates that were not changed afterwards. Exact-string metrics after NFC. Single run, single seed. "A" is ThakiOCR-KOEN-V1-Dense (2.13 M); "S1" is an internal 2.13 M model: A fine-tuned on AI Hub 71299 Training crops with an auxiliary spacing loss.
| Set | What it is | Metric | This model | A | S1 |
|---|---|---|---|---|---|
| Symbol test | 5,991 self-generated synthetic lines, new namespace, no text overlap with training | critical-token strict exact | 94.2% | 40.2% | 35.7% |
| Symbol test | same | CER | 0.40% | 10.38% | 12.91% |
| Real holdout, lines | 70 text lines from one held-out volume of AI Hub 71299 Training (evaluation only) | CER | 0.89% | 6.33% | 1.60% |
| Real holdout, all | 526 crops (456 words + 70 lines) from the same volume | CER | 1.11% | 8.48% | 2.50% |
| Real holdout, all | same | rows with digits, exact | 98.7% | 94.6% | 97.3% |
| Real holdout, all | same | date tokens exact | 3 / 4 | 4 / 4 | 4 / 4 |
Preregistered gates: I1 critical-token exact (pass), I2 won-sign family exact 99.9% (pass), I3 real-line CER below S1 (pass), I4 digits and dates on the real holdout (fail: dates 3 of 4), I5 size and CPU latency, 13.3 ms median per line (pass).
The symbol test was generated by our own renderer for the characters this model targets, so it measures exactly the skill we trained for and overstates accuracy on ordinary documents. The real holdout comes from the same dataset family as part of the training data.
Known limitations
- Gate I4 failed on dates. The one missed date was written with a space after the year's dot (form
YYYY. M.DD); the model dropped that space (YYYY.M.DD). Dates with inner spaces are a known weakness. On the internal real-document development sets, date-token exact was only 45% to 69%. - Tiny real holdout. The real independent set has 526 crops from a single volume and series, 70 of them full lines, and only 4 date tokens. One error moves the date score by 25 points; the confidence intervals are wide and a single-volume set says little about other document types.
₩versus₩. The two won signs look almost the same in the fonts we used. On the symbol test, strict currency exact is 81.0%, but if the two signs are treated as the same currency it is 99.9%: 427 rows swapped one for the other (301₩read as₩, 126₩read as₩). If your use needs the exact code point, do not rely on this model for it; if you only need the currency meaning, map both to KRW in post-processing (do not apply NFKC to whole strings, which also rewrites characters such as①).- Critical fields in financial and contract documents. Do not use this model to process critical fields (amounts, account or ID numbers, dates, contract terms) in financial or contract documents automatically. Date and won-sign errors above are exactly the failures that matter there; keep a human review step.
- No training data in this repository. The repository holds weights, code and these cards only. No AI Hub images, crops, labels or caches are included, and the training data is not distributed.
- Domain. Training used printed public documents and synthetic renderings. Photographed, handwritten, low-contrast or stylized text is out of scope.
- Line input only. Feeding a whole page or a multi-line block produces garbage. Lines wider than 2048 px after resizing are rejected.
- Batch effects. The depthwise convolution sees white padding at line ends, so a line's output can change slightly with the other lines in its batch.
- Single seed. Run-to-run variance was not measured.
Intended use
Research on Korean/English line recognition, especially symbol fidelity (currency signs, circled numbers, masked digits), inside a larger document pipeline. Not for unattended reading of financial, legal or identity documents.
Blog posts
Write-ups of this model on the ThakiCloud tech blog:
- ThakiOCR G2M: reading numbers and symbols more accurately
- Four open Korean OCR models, from 2M to 27B parameters
- ThakiOCR model hub: all four public OCR models
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 dataset 71299 (Training split) used for training under the AI Hub usage policy, not redistributed. Details in NOTICE.