Repository navigation
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 theinference_config_clsattribute to a subclass ofRecognitionInferenceConfigSegmentationInferenceConfig. These are exposed with-O/--option KEY=VALUEonkraken(segment,ocr) andketossubcommands. A newkraken options [MODEL_FILE]command has been adde to inspect supported options, and--archselectors onketos [train|segtrain](auto-detected from--load/--resumeartifacts) allow training recognition/segmentation plugins. - XML-Based Dataset Splits: Added
--xml-split/--no-xml-splittoketos compileto 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), andsplit_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,
krakenCLI parses PDFs lazily page-by-page,.safetensorsfiles are no longer opened twice. - Training & Inference Performance:
- PP-OCR neck and NRTR attention now use Flash Attention (
F.scaled_dot_product_attention), anddrop_last=Trueavoidstorch.compilerecompilations on the last batch. - Segmentation training: reduced dataset memory consumption by ~75% with
uint8target masks, runs BLLA val/test line vectorization on GPU, and avoids dataset lock contention duringim_mode/is_bitonalchecks.
- PP-OCR neck and NRTR attention now use Flash Attention (
- Default Recognition Model: Updated the default
kraken ocrmodel tomedium.safetensors(multilingual PP-OCRv6 medium) with a download hint (kraken get 10.5281/zenodo.21788409) when not installed. - Training CLI & Callbacks: Added
--sched-factorforReduceLROnPlateauacrossketos train,segtrain, andpretrain. - Model Compatibility:
load_safetensorschecks_kraken_min_versionmetadata from the weights file in addition to the module attribute. - Recognition Logits & Codecs: All recognition outputs (
CTCRecognitionInferenceMixinandTorchSeqRecognizer) now expose raw pre-softmax.logits.
Bug Fixes
- Fixed
ForcedAlignmentTaskModelaligning model predictions (record.text) instead of ground-truth transcripts (line.text), addedbboxsegmentation support, and fixed BiDi reordering and logit temperature scaling. - Fixed NRTR head under
bf16-true/fp16-trueprecision - Fixed vertical bbox cut scaling in
rpredandCTCRecognitionInferenceMixin. - 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 inketos 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,OneCycleLRstep counts. - Fixed 32-bit string offset overflow on large Arrow datasets (
pa.large_string()),pa.memory_maponPathobjects - Fixed unpicklable wildcard class maps in segmentation
- Fixed ALTO (
ComposedBlock,SP/String, XML comments inReadingOrder) and PageXML (word/glyphTextEquiv, invalid image dimensions, tag collection, customreadingOrder) parsing; fixed duplicate region IDs in serialization and ALTO/ABBYY/report template bugs - Legacy Alignment & Containers: Reimplemented legacy
kraken.alignon top of task helpers and raisedValueErrorwhenraise_on_erroris set - Preserve all attributes across BiDi reordering and fixed empty slicing and out-of-range indexing on
ocr_records. - fixed
DefaultAugmenterdevice mismatches,ImageInputTransformschannel-height permutation, andSegmentationTrainingDataConfigcounter overwrites. - fixed CoreML weight loading for nested VGSL containers
- fixed
create_modelwith class arguments, in-place parameter cloning inwrite_safetensors, - entry-point error handling in
find_checkpoint_module/find_weights_archs.