IHPAN/LightOnOCR-2-1B-ocr-sgkp
LightOnOCR-2-1B OCR SGKP LoRA
LoRA adapter fine-tuned for OCR of nineteenth-century Polish printed materials from the Geographical Dictionary of the Kingdom of Poland (SGKP). This repository contains the adapter and processor files, not a full copy of the base model.
Base Model
lightonai/LightOnOCR-2-1B-baseTraining Data
The model was fine-tuned on the IHPAN/ocr-sgkp dataset using 270 training pages and 30 validation pages. The transcriptions preserve historical spelling, Polish characters, punctuation, and text segmentation.
Training Configuration
- 4-bit NF4 QLoRA
- LoRA
r=8,alpha=16, dropout0.05, applied only to the language model - 5 epochs
- per-device batch size 1, gradient accumulation 8
- learning rate
5e-5 - maximum sequence length 3200
- longest image edge 768 px
- bf16 computation
- corrected Mistral tokenizer regular expression (
fix_mistral_regex=True)
Usage
import torch
from peft import PeftModel
from transformers import LightOnOcrForConditionalGeneration, LightOnOcrProcessor
base_model_id = "lightonai/LightOnOCR-2-1B-base"
adapter_id = "IHPAN/LightOnOCR-2-1B-ocr-sgkp"
processor = LightOnOcrProcessor.from_pretrained(
adapter_id,
fix_mistral_regex=True,
)
base_model = LightOnOcrForConditionalGeneration.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()Use LightOnOcrProcessor to prepare the image and chat template and to generate the transcription, following the same procedure as for the base model.
Evaluation
The following results were obtained on 10 manually transcribed SGKP pages that were excluded from the training and validation sets. Both models used the same plain-text transcription prompt and a generation limit of 3,072 new tokens.
Fine-tuning reduced CER by 0.2776 percentage points, corresponding to a 22.6% relative reduction. WER decreased by approximately 3.0% relative. The test set is small and comes from the same publication as the training material, so these figures should be treated as an in-domain preliminary evaluation rather than a general OCR benchmark.
Comparison of results with selected OCR models:
Limitations
- The model is specialized for the layout and typography of SGKP.
- Its performance may not generalize to other books, manuscripts, or modern printed materials.
- It returns plain text with individual dictionary entries separated into paragraphs.
- Before production use, the model should be evaluated on a larger independent test set.
- Use of this adapter is also subject to the license terms of the base model.
