Configuration Parsing Warning:In adapter_config.json: "peft.task_type" must be a string

ThakiOCR-Large-27B-R2B โ€” Korean Word OCR Research Preview

๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด ์นด๋“œ: MODEL_CARD.ko.md

A LoRA adapter (rank 32) for Qwen/Qwen3.6-27B that transcribes one cropped Korean word image into text. On a fixed internal development set of 2,400 word crops, it lowers character error rate (CER) from 18.04% (base model) to 6.01%.

This is a research preview, not a product release:

  • It reads single word crops only. Full-page OCR, line or paragraph reading, layout and reading order were not evaluated with this adapter.
  • Generalization to new fonts, new writers' documents, new document types or new capture conditions was not tested. The development set comes from the same source datasets as the training data (see Evaluation).
  • The extra gain from hard-character sampling over the uniform-sampling R2-A adapter (6.42% โ†’ 6.01%) is statistically borderline: its 95% CI upper bound is close to zero and reaches zero in a sensitivity analysis (see Results).
  • We make no claim of superiority over specialist OCR models. We did not run a head-to-head comparison under a shared protocol.

Usage

The adapter must be used with the exact protocol below. Other prompts, image sizes or sampling settings were not evaluated.

Setting Value
Base model Qwen/Qwen3.6-27B, revision 6a9e13bd6fc8f0983b9b99948120bc37f49c13e9
Prompt (Korean, verbatim) ์ด๋ฏธ์ง€์— ์ ํžŒ ๊ธ€์ž๋ฅผ ๊ทธ๋Œ€๋กœ ์˜ฎ๊ฒจ ์ ์œผ์„ธ์š”. ๊ธ€์ž๋งŒ ์ถœ๋ ฅํ•˜์„ธ์š”. ("Transcribe the text in the image exactly. Output only the text.")
Chat template one user turn: image, then prompt; add_generation_prompt=True, enable_thinking=False
Image size limits min_pixels = 64*64, max_pixels = 1024*1024
Decoding greedy (do_sample=False), max_new_tokens=64, batch 1
Precision bf16

The base model's generation_config.json enables sampling by default. Pass do_sample=False explicitly.

pip install torch "transformers>=5.0" "peft>=0.21" pillow
python inference_example.py --image word.png            # prints the transcription
python inference_example.py --image word.png --report   # JSON: text + load checks

inference_example.py pins the base revision, loads the adapter with PEFT and checks that 496 LoRA modules were attached, none of them in the vision tower. Core of it:

import torch, transformers
from peft import PeftModel
from PIL import Image

base = "Qwen/Qwen3.6-27B"; rev = "6a9e13bd6fc8f0983b9b99948120bc37f49c13e9"
processor = transformers.AutoProcessor.from_pretrained(base, revision=rev)
model = transformers.AutoModelForImageTextToText.from_pretrained(base, revision=rev, dtype=torch.bfloat16).to("cuda")
model = PeftModel.from_pretrained(model, "ThakiCloud/ThakiOCR-Large-27B-R2B").eval()

msgs = [{"role": "user", "content": [{"type": "image"},
         {"type": "text", "text": "์ด๋ฏธ์ง€์— ์ ํžŒ ๊ธ€์ž๋ฅผ ๊ทธ๋Œ€๋กœ ์˜ฎ๊ฒจ ์ ์œผ์„ธ์š”. ๊ธ€์ž๋งŒ ์ถœ๋ ฅํ•˜์„ธ์š”."}]}]
prompt = processor.tokenizer.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = processor(text=[prompt], images=[Image.open("word.png").convert("RGB")], return_tensors="pt",
                   images_kwargs={"min_pixels": 64 * 64, "max_pixels": 1024 * 1024}).to("cuda")
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(processor.tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip())

Hardware: about 53 GB GPU memory at batch 1 in bf16. Measured median latency was about 0.46 s per crop on one NVIDIA B200 (batch 1, internal measurement, not a serving benchmark).

Results โ€” word-crop CER on the fixed development set

CER = total character edits / total ground-truth characters, after Unicode NFC normalization and whitespace strip. Lower is better. 600 crops per source, 2,400 total, the same set for all three rows.

Model All (2,400) 91 handwriting 605 handwriting 91 printed 105 scene text
Qwen3.6-27B (base, same prompt) 18.04% 37.77% 23.76% 6.54% 10.38%
R2-A adapter (uniform sampling, reference) 6.42% 12.19% 6.31% 2.23% 6.71%
R2-B adapter (this release) 6.01% 12.27% 5.53% 1.61% 6.57%

Exact-match rate (whole word correct), all sources: base 72.7%, R2-A 84.0%, R2-B 85.2%.

Paired differences with 95% confidence intervals (stratified paired bootstrap over the 2,400 IDs, 2,000 resamples, pre-registered before results):

  • R2-B vs base, all sources: โˆ’12.03 pp [โˆ’14.88, โˆ’9.73]. No source got worse.
  • R2-B vs R2-A, all sources: โˆ’0.41 pp [โˆ’0.82, โˆ’0.03]. This extra gain is fragile: the upper bound is close to zero, and in a sensitivity analysis that drops 274 near-duplicate candidates the upper bound reaches 0.0. On 91 handwriting R2-B is not better than R2-A (+0.08 pp, writer-cluster CI [โˆ’0.89, +0.92] pp).

Diagnostics (descriptive, no CI): most of the base model's handwriting error on source 91 came from inserted characters (18.6% insertion rate), which fine-tuning removed. R2-B's extra gain over R2-A came mostly from digits and Latin characters and from characters seen 5โ€“49 times in training. It did not show up on characters seen 4 times or fewer.

Evaluation scope and caveats

  • In-distribution development set. The 2,400 crops were drawn from the official Validation splits of the same three datasets used for training. They are not an independent test set.
  • Leakage controls. Zero overlap between train and dev by file hash, decoded-pixel hash and source-image hash; zero overlap of 91-handwriting writers. Train images near-duplicate to dev candidates (dHash โ‰ค 4 and pHash โ‰ค 8) were removed from training.
  • 91 handwriting: 15 dev writers, all unseen in training. 15 groups is a small number, so writer-level CIs are wide.
  • 91 printed: the same 10 fonts appear in train and dev. This is a same-font result, not font generalization.
  • 605 and 105: no group key is available, so group-level generalization is not shown.
  • Model selection: the step-800 checkpoint was fixed in advance. Intermediate checkpoints were not used for the verdict.

Training

Item Value
Method LoRA r=32, alpha=64, dropout 0.05, on 496 decoder linear layers (attention and MLP). Vision tower and vision-language merger frozen. 233.5M trainable parameters
Steps 800, learning rate 1e-4, warmup 100, AdamW, effective batch 16 (2 GPUs ร— 8 accumulation)
Samples seen 12,800, each image at most once. Per source: 605 3,840 ยท 91 handwriting 3,840 ยท 91 printed 1,920 ยท 105 3,200
Sampler (R2-B) within each source, weighted draw without replacement; weight in [1, 2] by rank of mean character rarity (character frequencies from the training split only)
Training pools (after de-duplication) 91 handwriting 149,980 ยท 605 119,361 ยท 91 printed 20,927 ยท 105 33,105 crops
Compute about 3.4 GPU-hours on NVIDIA B200
Stack torch 2.13, transformers 5.15.1, peft 0.21.2

Related research result (no weights released)

A separate inference-only study (R3-0) used the R2-A adapter, not this one. Upscaling 91-handwriting crops 1.5ร— or 2.0ร— did not change R2-A's CER (2.0ร— vs 1.0ร—: +0.15 pp [โˆ’0.89, +1.15]). On a subset of 605 pages, giving the model the whole line instead of the single word lowered R2-A's word CER by 2.35 pp [โˆ’3.67, โˆ’1.17]. Both are research findings. No checkpoint was trained in R3-0 and they are not properties of this adapter.

Training data and attribution

This adapter was trained on data from AI ํ—ˆ๋ธŒ (AI-Hub, Korea's public AI training-data platform):

  • AI ํ—ˆ๋ธŒ(AI-Hub) โ€” ๋Œ€์šฉ๋Ÿ‰ ์†๊ธ€์”จ OCR ๋ฐ์ดํ„ฐ (605) โ€” large-scale handwriting OCR data
  • AI ํ—ˆ๋ธŒ(AI-Hub) โ€” ๋‹ค์–‘ํ•œ ํ˜•ํƒœ์˜ ํ•œ๊ธ€ ๋ฌธ์ž ์ด๋ฏธ์ง€ ์ธ์‹ ๋ฐ์ดํ„ฐ (91) โ€” Korean character image recognition data in various forms (handwritten and printed subsets)
  • AI ํ—ˆ๋ธŒ(AI-Hub) โ€” ์•ผ์™ธ ์‹ค์ œ ์ดฌ์˜ ํ•œ๊ธ€ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ (105) โ€” Korean text images photographed outdoors

Data redistribution is not permitted. The training and evaluation data, and anything derived from it (crops, label files, subsets, samples), are not included in this repository and are not shared. The data was used only for internal training and evaluation by the approved applicant. This card contains no sample images or texts from these datasets. To use the data, apply for it yourself on AI-Hub.

The printed subset of dataset 91 was rendered with third-party fonts whose rights are separate from AI-Hub's approval.

This repository contains no font files and no rendered font images. Publishing an adapter trained on images rendered with these fonts is different from redistributing the fonts themselves; only the LoRA weights are released.

Limitations

  • Word crops only. Feed one tight crop with one word. Multi-word lines, full pages or tables are out of scope.
  • Short outputs: max_new_tokens=64 matches word-level use.
  • Only Korean word images were evaluated. English-only or mixed-script inputs were not measured on their own.
  • The adapter does not change the vision encoder. Image-quality issues the base model cannot see remain.
  • This is a bf16 LoRA on a 27B model. A merged checkpoint would not be bit-identical to adapter inference. Only adapter inference was measured.

License

Apache License 2.0, the same license as the base model (see LICENSE). Use of the base model is governed by its own license. When you use this adapter, keep the attribution "AI ํ—ˆ๋ธŒ(AI-Hub)" and the dataset names above.

Downloads last month
3
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for ThakiCloud/ThakiOCR-Large-27B-R2B

Base model

Qwen/Qwen3.6-27B
Adapter
(588)
this model

Collection including ThakiCloud/ThakiOCR-Large-27B-R2B