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

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.

Metric Base Model Fine-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:

Model Samples CER WER
gemini 3.5 Flash Lite 10 0.65% 2.52%
LightOnOCR_sgkp 10 0.95% 4.22%
Mistral 4 ocr 10 0.97% 4.51%
Chandra 2 10 1.32% 3.11%

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.
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for IHPAN/LightOnOCR-2-1B-ocr-sgkp

Adapter
(13)
this model