Russian HTR Model (Puigcerver CRNN)

A Handwritten Text Recognition (HTR) model for 18th–20th century Russian manuscripts, printed books and typewritten documents, based on the CNN + BiLSTM + CTC architecture introduced in Puigcerver (2017) and used as the backbone of PyLaia and Transkribus.

This is a clean-room PyTorch reimplementation of that published architecture (PyLaia-inspired). It does not use the PyLaia Python package and is not loadable by it — training and inference run via plain PyTorch (see Usage below).

The model covers both pre-reform (pre-1918) and modern Russian orthography: about a quarter of the training lines show ѣ, і, ѳ or word-final ъ, and all four are part of the vocabulary.

Model Details

  • Architecture: CNN encoder [12, 24, 48, 48 filters] + 3-layer Bidirectional LSTM (256 units) + CTC decoder (Puigcerver 2017)
  • Input: Grayscale line images, normalized to 128 px height with aspect ratio preserved
  • Output: UTF-8 Russian Cyrillic text
  • Vocabulary: 246 symbols (symbols.txt), plus the CTC blank at index 0
  • Framework: Pure PyTorch — clean-room reimplementation of the Puigcerver (2017) architecture (PyLaia-inspired); the PyLaia package is not required

Performance

Metric Value
Validation CER 6.92%
Training epochs 80
Training lines 202,603
Training pages 6,145
Validation lines 13,903
Validation pages 430

The error distribution is strongly skewed: most lines are transcribed perfectly or near-perfectly, while a minority of hard lines carries a large share of the total character errors. The corpus CER above is therefore a poor predictor of quality on any single clean document, where the model typically performs considerably better.

Validation pages come from a separate Transkribus export. Three validation pages that were bit-identical to training pages were removed before scoring, so the reported CER contains no exact-duplicate leakage.

On 5 of the 430 validation pages the ground truth does not line up with the image lines (on four the transcriptions are assigned to the wrong lines of the page, on one most of the text belongs to a different page); the model reads most of these lines correctly and is scored against the wrong reference. These pages hold 219 lines (1.6%) but 8.4% of all character errors. In a separate per-line evaluation (6.96% CER overall) leaving them out lowers the CER to 6.44%. The figure above keeps them, since the annotation has not been corrected yet.

Training Data

Trained on Russian handwriting, print and typewritten text images transcribed in Transkribus: the training and validation sets of Generic Russian handwritten and typed 2. The material is deliberately heterogeneous — 18th-century printed books, 19th-century parish registers, personal correspondence and diaries, and 20th-century typescript — which is what the "generic" designation refers to.

The dataset grew in three steps:

  1. Russian generic handwriting 2 (Transkribus model 45595, Achim Rabus, 2022), with material from the MultiHTR project (Freiburg), the Estonian State Archive, the INEL project (Hamburg), the Prozhito project (St. Petersburg), the Ukraine Research Division of JewishGen, the Russian Civil Records model by IAJGS, the L'Dor V'Dor Foundation's Documentation of Jewish Records Worldwide (DoJR) and the HKR dataset.
  2. Russian generic handwritten and typed 1 (Transkribus model 148545, Aleksej Tikhonov, MultiHTR project, University of Freiburg), which added material from the Foundation of the International Memorial Association (with Aren Vanyan and Nikita Lomakin) and 18th-century Russian print from V. Okorokov's printing house (Kira Kovalenko, European University at St. Petersburg).
  3. Generic Russian handwritten and typed 2 (Achim Rabus; an internal Transkribus model), which added the diary Zapiski bolʹnoj by Tatʹjana Danina (1918–1921; University Library Bern, SOB RoEu ag 63, doi:10.7891/e-manuscripta-169904) and material from the National Archives of Finland.

Model curated by Achim Rabus (Slavic Department, University of Freiburg).

Usage

Requirements

The inference code lives in polyscriptor and imports other modules from it, so run it from a clone of the repository. Install into a fresh virtual environment in one pip call; requirements-kraken.txt adds the Kraken segmentation used for full pages below (for a GPU install, see the polyscriptor README):

git clone https://github.com/achimrabus/polyscriptor
cd polyscriptor
python3 -m venv htr_env && source htr_env/bin/activate
pip install -r requirements.txt -r requirements-kraken.txt
hf download achimrabus/crnn-ctc-russian --local-dir models/crnn-ctc-russian

Inference

From the root of the clone:

from inference_pylaia_native import PyLaiaInference
from PIL import Image

# Load model
model = PyLaiaInference(
    checkpoint_path="models/crnn-ctc-russian/best_model.pt",
    syms_path="models/crnn-ctc-russian/symbols.txt"
)

# Transcribe a line image
image = Image.open("line_image.jpg")
text, confidence = model.transcribe(image)
print(text, f"(confidence {confidence:.2f})")

Note: Input should be a single text line image, not a full page. Preprocessing (grayscale conversion, height normalization, aspect ratio preservation) is handled automatically by inference_pylaia_native.py.

For full-page inference with automatic line segmentation, use batch_processing.py. The neural Kraken segmenter (kraken-blla) is strongly recommended; the default projection-based segmenter (hpp) is fast but can miss most lines on complex pages:

python batch_processing.py \
    --engine crnn-ctc \
    --model-path models/crnn-ctc-russian/best_model.pt \
    --segmentation-method kraken-blla \
    --input-folder images/ \
    --output-folder output/

Web Interface (recommended)

polyscriptor's main interface runs in the browser: upload page images or PDFs, segment them automatically (Kraken) or reuse existing PAGE XML, transcribe, correct lines inline and export TXT, CSV or PAGE XML. It runs on a laptop or on a remote server (via SSH tunnel), and CRNN-CTC models also work without a GPU.

The web interface picks up any folder under models/ that contains best_model.pt and symbols.txt, so after the download above it only needs to be started:

uvicorn web.polyscriptor_server:app --host 0.0.0.0 --port 8765
# open http://localhost:8765 and choose the model under CRNN-CTC

Desktop GUI

polyscriptor also ships PyQt6 desktop interfaces: transcription_gui_plugin.py for interactive single pages (automatic line segmentation, PAGE XML export) and polyscriptor_batch_gui.py for whole folders (uses existing PAGE XML files, e.g. from Transkribus, when available).

Intended Use

  • Transcription of 18th–20th century Russian handwritten, printed and typewritten documents
  • Russian historical document digitization, including pre-reform orthography
  • A general-purpose starting point for finetuning on a specific hand, scribe or collection

Limitations

  • Trained on line images cropped to the bounding box of each line, matching what the segmentation stage produces at inference time. On densely written pages the crops include ascenders and descenders from neighbouring lines, and the model has learned to tolerate this — but severely overlapping lines remain difficult.
  • Being a generic model, it is outperformed by a model finetuned on a single hand. For a homogeneous collection, finetuning from this checkpoint is usually worth the effort.
  • Full-page segmentation quality depends on the segmentation method used upstream.
  • The orthography of the ground truth is not uniform: some of the older material was transcribed with pre-1918 letters, some with their modern equivalents. The model may therefore output either convention for pre-reform text.
  • Marginalia, stamps, tables and heavily abbreviated administrative formulae are underrepresented in the training data.

Citation

If you use this model in your research, please cite the architecture paper and this model:

@article{puigcerver2017multidimensional,
  title     = {Are Multidimensional Recurrent Layers Really Necessary for Handwritten Text Recognition?},
  author    = {Puigcerver, Joan},
  journal   = {Proceedings of the 14th IAPR International Conference on Document Analysis and Recognition (ICDAR)},
  year      = {2017},
  url       = {https://www.jpuigcerver.net/pubs/jpuigcerver_icdar2017.pdf}
}

@misc{rabus2026polyscriptor,
  title  = {Polyscriptor: Multi-Engine HTR Training \& Comparison Tool},
  author = {Rabus, Achim},
  year   = {2026},
  url    = {https://github.com/achimrabus/polyscriptor}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support