ksk00/donut-docai
17
donut-docai — Korean Transaction-Statement Parser
Fine-tuned Donut (naver-clova-ix/donut-base) that reads a Korean transaction statement (거래명세표 / 계산서) image and outputs structured JSON — no OCR + rule engine.
Code & full pipeline: https://github.com/KyoungsoonKim00/donut-document-ai
Usage
import torch
from PIL import Image
from transformers import DonutProcessor, VisionEncoderDecoderModel
processor = DonutProcessor.from_pretrained("ksk00/donut-docai")
model = VisionEncoderDecoderModel.from_pretrained("ksk00/donut-docai")
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device).eval()
image = Image.open("document.png").convert("RGB")
pixel_values = processor(image, return_tensors="pt").pixel_values.to(device)
decoder_input_ids = processor.tokenizer(
"<s_gt_parse>", return_tensors="pt", add_special_tokens=False
).input_ids.to(device)
outputs = model.generate(
pixel_values, decoder_input_ids=decoder_input_ids,
max_length=512, num_beams=5,
pad_token_id=processor.tokenizer.pad_token_id,
eos_token_id=processor.tokenizer.eos_token_id,
)
print(processor.batch_decode(outputs, skip_special_tokens=True)[0])Output schema
Training
- Base:
naver-clova-ix/donut-base(Swin-B encoder + mBART decoder) - Image size 720×960, task prompt
<s_gt_parse>, max length 512 - AdamW lr 5e-5, weight decay 0.01, warmup 5%, 15 epochs, fp16, gradient checkpointing
Limitations
Trained on a small in-house dataset (tens of documents). The model overfits and can collapse into repeated tokens on unseen layouts. Treat as a proof-of-concept, not production-ready. See the GitHub repo for improvement directions.
