CoolFace
Modelpublic

IHPAN/LightOnOCR-2-1B-ocr-sgkp

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes12downloads
Model Card

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

text
lightonai/LightOnOCR-2-1B-base

Training 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, dropout 0.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

python
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.

MetricBase ModelFine-tuned Model
Character Error Rate (CER)1.2264%0.9488%
Word Error Rate (WER)4.3541%4.2233%

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:

ModelSamplesCERWER
gemini 3.5 Flash Lite100.65%2.52%
LightOnOCR_sgkp100.95%4.22%
Mistral 4 ocr100.97%4.51%
Chandra 2101.32%3.11%
Tesseract 5.5107.70%30.46%

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.