Skip to content

7.3 release

Latest

Choose a tag to compare

@mittagessen mittagessen released this 04 Dec 12:16

kraken 7.3

This release primarily adds better integration of plugins both with inference by allowing custom configuration options to be exposed through the standard CLI commands and training by adding additional metadata class attributes that allow training with kraken's own recognition/segmentation trainers. The large number of small bug fixes, code cleanup, and deduplication are the result of an AI-assisted code review with Gemini 4 Carbon.

This release also includes various small performance improvements that should speed up recognition modestly and reduce memory pressure due to IPC, in particular with large worker pools and GPU inference. While exact numbers are highly dependent on the individual setup, we typically see ~10% higher throughput with significant memory savings.

Highlights

  • Custom Model Options & Plugin Training: Plugins can now expose custom configuration fields
    by setting the inference_config_cls attribute to a subclass of RecognitionInferenceConfig SegmentationInferenceConfig. These are exposed with-O/--option KEY=VALUE on kraken (segment, ocr) and ketos subcommands. A new kraken options [MODEL_FILE] command has been adde to inspect supported options, and --arch selectors on ketos [train|segtrain] (auto-detected from --load/--resume artifacts) allow training recognition/segmentation plugins.
  • XML-Based Dataset Splits: Added --xml-split/--no-xml-split to ketos compile to emit separate {stem}_{split}{suffix} Arrow shards (train, validation, test) from XML line split tags. This is a replacement for the previous intra-shard splits that were impractical due to preventing memory mapping of the dataset.

Breaking Changes

  • Fixed PP-OCR recognition batch-size dependence (#810) via masked SE pooling and right-context padding during inference. Incorrect padding handling raised inference CER by ~1.0-1.5pp. Existing models are not repaired with this patch but fine-tuning on the original training dataset for 1-2 epochs will most likely adapt the model to the different padding masks.
  • Deprecated Binary Dataset Split Options: binary_dataset_split (RecognitionTrainingDataConfig), ignore_splits (build_binary_dataset), and split_filter (ArrowIPCRecognitionDataset) are now deprecated and ignored (scheduled for removal in kraken 8).
  • Stricter VGSL Spec Parsing: VGSL layer spec parsers now use fullmatch, rejecting specs with trailing garbage.
  • Removed Unused Exceptions: Dropped unused exception classes from kraken.lib.exceptions (KrakenStopTrainingException, KrakenRecordException, KrakenRepoException, KrakenCairoSurfaceException).

Changes & Improvements

  • Recognition crops line patches before multiprocessing IPC, kraken CLI parses PDFs lazily page-by-page, .safetensors files are no longer opened twice.
  • Training & Inference Performance:
    • PP-OCR neck and NRTR attention now use Flash Attention (F.scaled_dot_product_attention), and drop_last=True avoids torch.compile recompilations on the last batch.
    • Segmentation training: reduced dataset memory consumption by ~75% with uint8 target masks, runs BLLA val/test line vectorization on GPU, and avoids dataset lock contention during im_mode/is_bitonal checks.
  • Default Recognition Model: Updated the default kraken ocr model to medium.safetensors (multilingual PP-OCRv6 medium) with a download hint (kraken get 10.5281/zenodo.21788409) when not installed.
  • Training CLI & Callbacks: Added --sched-factor for ReduceLROnPlateau across ketos train, segtrain, and pretrain.
  • Model Compatibility: load_safetensors checks _kraken_min_version metadata from the weights file in addition to the module attribute.
  • Recognition Logits & Codecs: All recognition outputs (CTCRecognitionInferenceMixin and TorchSeqRecognizer) now expose raw pre-softmax .logits.

Bug Fixes

  • Fixed ForcedAlignmentTaskModel aligning model predictions (record.text) instead of ground-truth transcripts (line.text), added bbox segmentation support, and fixed BiDi reordering and logit temperature scaling.
  • Fixed NRTR head under bf16-true/fp16-true precision
  • Fixed vertical bbox cut scaling in rpred and CTCRecognitionInferenceMixin.
  • Fixed bounding regions so all containing regions constrain line polygonization
  • Fixed centerline polygonization (topline=None) in the new segmentation API
  • Unified padding across datasets and inference
  • Fixed a heuristic reading order regression for touching lines and RTL multi-column layouts
  • Fixed neural RO index remapping in blla.py, and class mapping extraction in ketos rotrain (#821, #822).
  • Disabled augmentation on auto-split validation sets (and enabled it on auto-split recognition training sets)
  • Fixed LR warmup from step 0 and with AdamW+Muon, OneCycleLR step counts.
  • Fixed 32-bit string offset overflow on large Arrow datasets (pa.large_string()), pa.memory_map on Path objects
  • Fixed unpicklable wildcard class maps in segmentation
  • Fixed ALTO (ComposedBlock, SP/String, XML comments in ReadingOrder) and PageXML (word/glyph TextEquiv, invalid image dimensions, tag collection, custom readingOrder) parsing; fixed duplicate region IDs in serialization and ALTO/ABBYY/report template bugs
  • Legacy Alignment & Containers: Reimplemented legacy kraken.align on top of task helpers and raised ValueError when raise_on_error is set
  • Preserve all attributes across BiDi reordering and fixed empty slicing and out-of-range indexing on ocr_records.
  • fixed DefaultAugmenter device mismatches, ImageInputTransforms channel-height permutation, and SegmentationTrainingDataConfig counter overwrites.
  • fixed CoreML weight loading for nested VGSL containers
  • fixed create_model with class arguments, in-place parameter cloning in write_safetensors,
  • entry-point error handling in find_checkpoint_module / find_weights_archs.