Computational Linguistics in Bulgaria

ISSN (print): 3033-1382 | ISSN (online): 3033-2397

Computational Linguistics in Bulgaria, 2026, 2 (1): 125–156

DOI: 10.47810/JCLIB.2.2026.06

PDF

Extraction of Handwritten and Printed Cyrillic Text from Documents: A Resource-Efficient Pipeline

Daniel Halachev1, Ivan Koychev1

1 Sofia University “St. Kliment Ohridski”, Sofia, Bulgaria — danihalachev@gmail.com, koychev@fmi.uni-sofia.bg

Abstract

The digitisation of historical, administrative, and personal documents in Bulgarian faces considerable challenges due to the lack of robust Optical Character Recognition (OCR) and Handwritten Text Recognition (HTR) systems tailored for the Cyrillic alphabet. While modern Vision-Language Models (VLMs) and large transformer-based architectures achieve state-of-the-art results, their performance and resource efficiency on low-resource languages remain prohibitive for decentralised, privacy-preserving applications. In this paper, we present a comprehensive, resource-efficient pipeline for extracting printed and handwritten Cyrillic text. Our system integrates advanced image preprocessing, YOLO-based document structure and table recognition, and a Permuted Autoregressive Sequence (PARSeq) model trained specifically for Bulgarian. We generated custom synthetic Bulgarian cursive datasets to mitigate the severe lack of real-world training data. Our evaluation indicates that the specialised PARSeq model outperforms traditional OCR tools such as Tesseract and EasyOCR on our custom degraded printed test set, and provides a practical, resource-efficient baseline for handwriting recognition compared to a modern local VLM (Qwen3-VL-4B). Finally, we discuss the discrepancy between synthetic and real handwritten data, highlighting the urgent need for a standardised, annotated Bulgarian HTR dataset.

Keywords: Optical Character Recognition, Handwritten Text Recognition, Bulgarian Language, Cyrillic Alphabet, PARSeq, Document Layout Analysis

1. Introduction

The modern world relies heavily on digital information, yet a vast amount of historical, administrative, and cultural data in Bulgarian remains locked in physical paper documents. The automatic extraction of text from these documents—Optical Character Recognition (OCR) and Handwritten Text Recognition (HTR)—is essential for preserving, searching, and analysing this data. Documents such as exams, homework, essays, forms, books, magazines, and archival records contain valuable information that is yet to be digitised and analysed in its entirety. Such a system would improve accessibility and inspire future Bulgarian OCR research.

Despite substantial advancements in OCR technologies, most existing libraries and commercial systems are heavily optimised for the Latin alphabet. Tools that support Cyrillic often exhibit unsatisfactory accuracy, particularly when processing highly degraded printed text or cursive handwriting. Furthermore, while recent Large Language Models (LLMs) and Vision-Language Models (VLMs) have revolutionised natural language processing, their application to document recognition introduces severe drawbacks regarding high computational costs and privacy concerns when sending sensitive documents to third parties.

This research investigates the feasibility of using lightweight, highly efficient architectures for Bulgarian text recognition. Rather than relying on massive, resource-intensive models, we focus on optimising the quality-speed-cost trilemma through targeted experiments and architectural choices. A driving factor for our methodology was the strict requirement that the system must run locally on consumer-grade hardware (e.g. a standard laptop with 16 GB of RAM and an 8-core CPU). This constraint is essential to ensure data privacy, decentralisation, and accessibility. The primary goal was to design and evaluate a complete pipeline for recognising printed and handwritten Cyrillic text that is accurate, usable, and resource-efficient. To support practical digitisation workflows, the system was designed to expose a REST API and output results in standardised formats such as plain text, ALTO XML, and HOCR. Table 1 summarises the practical constraints that shape the full system.

Table 1. Practical constraints shaping the system architecture.
AspectConstraint or Objective
HardwareLocal execution on 16 GB RAM and 8 CPU cores
DeploymentPrivacy-preserving, open-source, locally runnable
InterfaceBrowser GUI and REST API
OutputsPlain text, ALTO XML, HOCR

To achieve these goals, we developed a complete document processing pipeline. We investigated the feasibility of using lightweight, highly efficient architectures for Bulgarian text recognition. We trained and evaluated a Permuted Autoregressive Sequence (PARSeq) (Bautista and Atienza 2022) model and benchmarked it against widely used open-source tools, Tesseract (Smith 2007) and EasyOCR (Kittinaradorn et al. 2020), as well as a local VLM, Qwen3-VL-4B (Qwen Team 2025).

In summary, our main contributions are:

To support reproducibility, the source code of the system is provided as anonymised supplementary material for review and will be made publicly available upon publication.

2. Related Work

The field of text recognition has evolved substantially from early mechanical devices to modern deep learning architectures. Early OCR systems relied on explicit character segmentation followed by classification using matrix matching or feature extraction combined with classifiers like Support Vector Machines (SVMs) or k-Nearest Neighbours (k-NN). Systems like Tesseract and EasyOCR remain standard open-source baselines due to their accessibility. However, they struggle considerably with cursive handwriting and heavily degraded documents due to their reliance on brittle segmentation algorithms.

The paradigm shifted with the introduction of Convolutional Neural Networks (CNNs) for feature extraction, which replaced manual engineering of shape descriptors with automatic representation learning. The subsequent introduction of Recurrent Neural Networks (RNNs), specifically Long Short-Term Memory (LSTM) networks, and the Connectionist Temporal Classification (CTC) loss function (Graves et al. 2006) allowed for end-to-end sequence recognition without explicit segmentation. This led to the popular Convolutional Recurrent Neural Network (CRNN) architecture (Shi et al. 2017).

More recently, transformer-based architectures have dominated academic research in text recognition. Models such as ABINet (Fang et al. 2021), ViTSTR (Atienza 2021), and TrOCR (Li et al. 2022) leverage self-attention mechanisms to capture complex spatial and linguistic dependencies in parallel. While models like TrOCR achieve state-of-the-art results by combining powerful visual encoders with language-aware decoders, they often demand substantial computational resources and large labelled corpora, making them difficult to deploy in decentralised, low-resource environments.

To balance accuracy and efficiency, the PARSeq (Permuted Autoregressive Sequence) architecture was introduced. It utilises a Vision Transformer (ViT) (Dosovitskiy et al. 2021) encoder and a permutation-based autoregressive decoder. By training on permuted reading orders, it learns ensembles of internal language models, making it highly robust to noise and occlusion while remaining lightweight and fast during inference.

Modern multimodal large language models and document-understanding systems, such as Donut or GPT-family models, can perform OCR-like tasks as part of broader image understanding. However, these systems are not optimised specifically for text recognition, consume disproportionate resources, and create privacy concerns when documents must be sent to third-party infrastructure.

Cyrillic and Bulgarian text recognition. High-accuracy Cyrillic OCR systems are rare, and most public resources target Russian and Kazakh. For Bulgarian, existing work focuses on printed and historical text: using Bulgarian language resources to post-correct OCR output (Kratchanov et al. 2020), and a benchmark with methods for post-OCR correction of historical documents in pre-1945 orthography (Beshirov et al. 2025). Tesseract and EasyOCR handle printed Bulgarian reasonably well, but no system reliably recognises Bulgarian cursive, which is the gap we address.

3. Proposed Methodology

To handle the high variance of real-world documents, the system is designed as a modular pipeline: Image Input → Preprocessing → Text Detection → Structure Recognition → Text Recognition → Output. Full-document recognition was rejected due to the lack of suitable annotated datasets and the insufficiency of synthetic data alone for reliable real-world performance.

3.1. System Architecture and Preprocessing

Document images often suffer from noise, poor lighting, stains, and geometric distortions. The system implements a suite of selectable preprocessing techniques to normalise the input. Crucially, preprocessing is treated as a configurable search space rather than a fixed recipe. Because the effect of preprocessing cannot be predicted reliably in advance, the system allows arbitrary user-selected preprocessing sequences. These dependencies form a Directed Acyclic Graph (DAG) of valid combinations.

The image representation is another critical design choice. Images are stored in the LAB colour space, where the L channel acts as a luminance-based black-and-white representation, while the A and B channels preserve colour information. This allows grayscale-style algorithms to operate only on the L channel, while spatial transformations (such as deskewing or dewarping) are propagated consistently to all channels. This enables in-place processing with good cache locality and minimal copying.

Comparison of processing in RGB vs. LAB colour space. Operating on the L channel preserves colour information while allowing grayscale algorithms to f
Figure 1. Comparison of processing in RGB vs. LAB colour space. Operating on the L channel preserves colour information while allowing grayscale algorithms to function correctly.

The implemented preprocessing techniques are categorised into four main areas to handle the wide variety of degradations found in historical and administrative documents:

3.2. Text Detection and Structure Recognition

Accurate text recognition requires precise localisation. To locate text bounding boxes, the system supports either CRAFT (Baek et al. 2019) or YOLO-family text detectors (Jocher et al. 2024), exposed as interchangeable backends so users can choose whichever works best on their material without tying the write-up to a specific model version or training recipe.

For document structure recognition, we use an off-the-shelf layout detector from the YOLO family (Ultralytics 2023) (release/version not fixed in our pipeline) whose published weights were trained on DocLayNet (Pfitzmann et al. 2022); we did not train this component ourselves. It exposes high-level region classes (paragraphs, titles, lists, figures). However, most layout detection algorithms only recognise these broad semantic elements and do not support individual text line extraction. Furthermore, bounding-box regression models can be highly sensitive to document defects, often fragmenting paragraphs incorrectly when faced with skewed or degraded scans.

To address this, we cluster word-level detections into lines (and optionally group lines into blocks) with DBSCAN (Ester et al. 1996): the algorithm does not require a fixed number of clusters in advance and drops isolated noise. Radius ε is set proportional to row height to track font size, with boxes sorted by reading order. This is a lightweight geometric glue layer between detection and recognition, not a full document-understanding model.

Additionally, we integrate a YOLO-based table detector using weights trained on PubTables-1M (Smock et al. 2022) (released checkpoints; we did not train this submodule from scratch), extending the prototype toward broader document understanding.

3.3. Text Recognition Model Selection

Our approach relies on word-level recognition, offering the optimal compromise between visual difficulty, available data, latency, and the ability to leverage implicit language modelling.

Before selecting the final architecture, we conducted controlled experiments comparing three distinct paradigms: a custom CNN + Transformer Decoder, a Deformable CNN (DCNN) (Zhu et al. 2018) + Transformer Decoder, and PARSeq.

The baseline architecture evaluated during preliminary experiments, consisting of a ResNet-50 feature extractor coupled with a Transformer Decoder.
Figure 2. The baseline architecture evaluated during preliminary experiments, consisting of a ResNet-50 feature extractor coupled with a Transformer Decoder.

The CNN + Transformer Decoder served as our baseline. Our experiments revealed that a full encoder-decoder transformer is unnecessary; a lightweight transformer decoder paired with a strong CNN feature extractor is sufficient for the language-modelling component. We then hypothesised that Deformable Convolutions (DCNN), which adapt their receptive fields to the geometric variations of the input, would excel at capturing the high variance of cursive handwriting.

Validation CER for CNN + Decoder Transformer vs. DCNN + Decoder Transformer (same decoder). The DCNN encoder minimises error more slowly than the stan
Figure 3. Validation CER for CNN + Decoder Transformer vs. DCNN + Decoder Transformer (same decoder). The DCNN encoder minimises error more slowly than the standard CNN backbone.

Surprisingly, replacing standard convolutions with DCNNs resulted in slower convergence and inferior accuracy (Figure 3). The deformable filters struggled to find consistent patterns in the highly irregular handwritten strokes.

Ultimately, PARSeq demonstrated better efficiency, faster convergence, and lower Character Error Rate (CER). The PARSeq model represents a substantial departure from traditional CRNN architectures by addressing the limitations of both purely autoregressive (AR) models (which suffer from error accumulation) and non-autoregressive (NAR) models (which lack language modelling capabilities).

PARSeq employs a Vision Transformer (ViT) as its visual encoder. The ViT processes the input image as a sequence of non-overlapping patches, utilising self-attention to capture global spatial dependencies across the entire image. This is particularly advantageous for highly degraded text, where local features might be obscured, but global context can aid recognition.

The decoder is a lightweight, permutation-based autoregressive transformer. During training, PARSeq generates the target text sequence using multiple permuted reading orders. Predicting characters from arbitrary context subsets enables the model to learn an internal language model ensemble. During inference, it can operate in a standard left-to-right AR mode for maximum accuracy, or in an iterative refinement mode where it uses bidirectional context to correct initial predictions. This flexibility makes PARSeq robust to the high variance and occlusions typical of handwritten Cyrillic text.

The PARSeq architecture, utilising a ViT encoder and a permutation-based autoregressive decoder.
Figure 4. The PARSeq architecture, utilising a ViT encoder and a permutation-based autoregressive decoder.

Handling both printed and handwritten styles with a single model presents challenges like catastrophic forgetting. To mitigate the issue, we considered explicit style tokens (e.g.\ [HAND] and [PRINT]) as a lightweight way to condition a single recogniser so print and handwriting share weights instead of separate heads. This approach is applicable to all architectural variants, including PARSeq, but we did not pursue it, for three reasons. First, the architecture comparison had already consumed much of our experimental budget, and evaluating style conditioning properly would have required a separate set of experiments. Second, we expected little benefit: PARSeq is a strong recogniser and should handle both styles without an explicit switch, whereas a style token adds a single point of failure, since a misclassified style propagates errors through the rest of the pipeline. Third, the ViT encoder already handles most of the recognition, so conditioning the smaller decoder would have limited effect.

3.4. Datasets and Training Curriculum

A major challenge in developing HTR systems for Bulgarian is the severe lack of annotated real-world datasets. To overcome this, we utilised a combination of synthetic and real-world Cyrillic datasets. For printed text, we utilised the MJSynth dataset (Jaderberg et al. 2014) (a massive collection of synthetic Latin scene text) to provide a strong baseline for visual feature extraction and regularisation. For printed Cyrillic, we aggregated several synthetic datasets (OCR Cyrillic Printed 1, 9, and 10), which contain millions of rendered words in various standard Cyrillic fonts.

For handwriting, due to the severe lack of real-world Bulgarian data, we generated four custom synthetic corpora based on free fonts that mimic different handwriting and typewritten styles: Pacifico (connected cursive), MarckScript (loose cursive), Comforter (informal handwriting), and GNU Typewriter (typewritten). The generation process involved rendering text with random variations in font size, spacing, and stroke width. During training, rendered line images were further augmented (Gaussian and motion blur, elastic warping, random paper textures and stains) to mimic degraded scans and historical documents. These were combined with a corpus of the 714,876 most frequent words from the Bulgarian Wikipedia (Kostov 2011). All single-letter words except the high-frequency prepositions/conjunctions were excluded. This exposes the model to Bulgarian vocabulary and orthographic patterns rather than relying only on foreign-language Cyrillic corpora.

For real-world handwriting, we incorporated the Cyrillic Handwriting Dataset (Werner 2021) (primarily Russian cursive) and the Kazakh Offline Handwritten Text Dataset (KOHTD) (Toiganbayeva et al. 2022). The KOHTD corpus was further processed to remove examples containing characters specific to the Kazakh alphabet that were outside our defined support set.

Training a single model to recognise both styles requires careful curriculum learning. We utilised a four-phase strategy:

3.5. Implementation Details

The entire system was developed to run under resource constraints, ensuring it remains accessible to the general public, not just well-funded research institutions. The system is formally constrained to run locally on consumer-grade hardware on the order of 16 GB RAM and an 8-core CPU. This constraint guarantees privacy, as sensitive documents never leave the user’s device.

To maximise extensibility, the backend exposes its functionality via a REST API. This allows the recognition engine to be integrated into broader document management systems or archival workflows. The system supports multiple standardised output formats: plain text for simple search and retrieval tasks, ALTO XML for describing the layout and content of physical text documents (preserving bounding box coordinates and reading order), and HOCR for embedding layout information directly into HTML.

Training deep learning models on millions of high-resolution images required a deliberate data pipeline. An initial attempt to stream examples directly from remote storage proved too slow for our setup and made proportional mixing across corpora difficult. We therefore converted all training corpora into compact WebDataset tar shards, stored them locally on the training machine, and fed them through PyTorch Dataset/DataLoader with multiple worker processes to overlap decoding, on-the-fly augmentation, and GPU compute.

4. Experiments and Results

We run two experiments. The first measures the final model on the held-out test splits of the training corpora, under conditions close to the training distribution, to establish an upper bound. The second measures it on real, unseen Bulgarian documents and compares it against widely used OCR tools and a local vision-language model, to test how far that accuracy carries to practical use.

We report CER and Word Error Rate (WER) throughout. Both are standard for OCR and HTR: CER captures character-level mistakes, and WER reflects whole-word usability, which is what matters for downstream search and indexing.

4.1. Test Set Performance

This first experiment measures the final model on the held-out test split of every training corpus, so accuracy is assessed under conditions that match training. To quantify uncertainty, we computed Wilson 95% confidence intervals (CIs) and two-proportion z-tests between the Phase 2 and final Phase 3 checkpoints on the real handwritten corpora. The final PARSeq model achieved strong results on the test splits of the training data. Table 2 summarises point estimates. Held-out sample sizes ranged from 14,831 characters (2,156 words) on the Cyrillic Handwriting Dataset to 5,398,419 characters (822,035 words) on Synthetic Cyrillic Large (PUMB AI 2024); normal approximations for the z-tests were appropriate throughout. Table 3 reports CIs at the final checkpoint. Table 4 summarises phase-to-phase significance. The model achieves high accuracy on stylistically controlled synthetic data, and scores on real-world sets provide an adequate baseline for generalisation to unseen Bulgarian cursive.

Table 2. Detailed Character Error Rate (CER) and Word Error Rate (WER) of the final PARSeq model on the test splits of the training corpora.
DatasetCER (%)WER (%)
MJSynth (Latin)5.6310.61
OCR Cyrillic Printed (Combined)3.8717.70
BulgarianPacifico0.030.29
BulgarianMarckScript0.030.23
BulgarianComforter0.050.41
BulgarianGNUTypewriter0.030.27
Synthetic Cyrillic Large6.1527.20
Cyrillic Handwriting Dataset9.0339.28
KOHTD7.3825.46
Table 3. Wilson 95% CIs for the final Phase 3 checkpoint on real handwritten test splits.
DatasetCER95% CIWER95% CI
Cyrillic Handwriting9.03%[8.58, 9.50]39.28%[37.24, 41.35]
KOHTD7.38%[6.98, 7.80]25.46%[23.91, 27.07]
Table 4. Phase 2 vs. final Phase 3 checkpoints on real handwritten corpora (two-proportion z-tests).
DatasetMetricPhase 2Finalp (z-test)
Cyrillic HandwritingCER28.31%9.03%7.37 × 10−7
Cyrillic HandwritingWER82.42%39.28%6.88 × 10−4
KOHTDCER37.65%7.38%≈ 0
KOHTDWER86.58%25.46%≈ 0

4.2. Real-World Comparison

To evaluate practical applicability, we constructed a custom test set. For printed text, we randomly selected highly degraded documents from a small subset of the Bulgarian National Radio’s archive.1 For handwritten text, we collected paragraphs randomly chosen from Wikipedia, featuring three distinct cursive styles. The ground truth for these samples was manually transcribed and verified by a native Bulgarian speaker. For these multi-line documents, predicted and ground-truth lines are aligned via the Hungarian algorithm on edit-distance costs before CER/WER are computed; unpaired lines count as full errors. We compared our PARSeq implementation against Tesseract and EasyOCR (for printed) and Qwen3-VL-4B-8bit (for handwritten).2 To ensure a fair zero-shot evaluation on real-world document conditions, Tesseract and EasyOCR were evaluated out-of-the-box using their standard Bulgarian extensions and dictionaries without any further fine-tuning. Similarly, our PARSeq model was trained strictly on the training corpora splits and was not fine-tuned on any samples from this custom test set.

Results on Printed Text: As shown in Table 5, PARSeq outperformed both Tesseract and EasyOCR on degraded typewritten documents. The bidirectional context of PARSeq allowed it to correctly infer characters obscured by noise, whereas traditional OCR tools failed at the segmentation stage.

Table 5. Average results on degraded printed documents.
ModelCER (%)WER (%)Time (s)
Tesseract12.933.58.2
EasyOCR14.143.83.1
Ours9.428.15.1

Results on Handwritten Text: Recognising real-world Bulgarian handwriting proved considerably more challenging. Table 6 compares PARSeq against Qwen3-VL-4B-8bit. While dedicated HTR architectures like TrOCR exist, they typically lack out-of-the-box support for Bulgarian cursive and would require resource-intensive pre-training. Instead, we selected Qwen3-VL-4B-8bit as our primary baseline because it was the strongest open-weights Vision-Language Model we identified that supports Bulgarian and still fits within our strict hardware constraints. Furthermore, benchmarking against a VLM reflects the current real-world trend of relying on general-purpose assistants for document understanding tasks. In this comparison, PARSeq outperformed the local VLM on the handwritten test set. Qwen3-VL suffered from context explosions and hallucinations on high-resolution images and sometimes stopped reading abruptly. Resource consumption was also much lower: roughly 4–6 GB vRAM for DocRec versus 12–16 GB vRAM for Qwen3-VL-4B-8bit.

Table 6. Average results on handwritten documents across three cursive styles.
ModelCER (%)WER (%)
Qwen3-VL-4B-8bit56.484.1
Ours17.245.3

5. Discussion and Limitations

The Synthetic vs.\ Real Data Discrepancy: Loss curve analysis (Figure 5) reveals a negative correlation between synthetic and real handwriting data: while they share useful structure, synthetic cursive often fails to capture the variability, slant, and stroke continuity of real handwriting. This is reflected in the phase-wise accuracy trends (Table 7), where performance on real data improves substantially only during the final adaptation stage. Overall, data scarcity, rather than model complexity, remains the primary constraint, limited by the lack of large-scale, annotated Bulgarian HTR datasets.

Table 7. Phase-wise development of recognition accuracy. Real-handwriting performance improves sharply only in the final adaptation stage, justifying the staged curriculum.
StagePrinted CER (%)CHD CER (%)KOHTD CER (%)
Phase 07.40
Phase 13.10
Phase 23.4328.3137.65
Phase 33.986.116.68
Final Test3.879.037.38
The observed discrepancy between validation loss on synthetic datasets and real-world handwritten datasets, highlighting the limitations of purely syn
Figure 5. The observed discrepancy between validation loss on synthetic datasets and real-world handwritten datasets, highlighting the limitations of purely synthetic training.

Error Analysis: The real-world results are lower than the test-split results for two main reasons:

Per-character errors were limited mostly to confusions between visually similar letters. On the real-world samples these were о/с (where ink had worn away), г/т in plain handwriting, and ъ/ь. In cursive handwriting, where ligatures are denser, the most frequently confused pairs were а/о, и/ш, е/с, н/п and к/н. The high character and word error rates were mostly driven by ligatures in dense handwriting, where the model struggled to separate individual characters. This is somewhat surprising, considering the model does not rely on explicit segmentation and should, in principle, cope with connected letters. In certain limited cases, the slant of the lines also caused confusion, as words were appended to the wrong line.

Opportunities for Improvement: To improve accuracy on highly variable real-world Bulgarian handwriting, addressing the data deficit remains the most critical step. Building large, annotated corpora is essential and can be achieved through institutional data collection. For example, universities could systematically gather student-written materials and integrate lightweight annotation into coursework, enabling continuous corpus growth.

In parallel, exploring larger model architectures, combined with efficiency techniques such as quantisation or knowledge distillation, offers a practical path to increased capacity within fixed hardware constraints. Recent methods such as Google’s TurboQuant further highlight the potential for optimisation without prohibitive computational cost.

The Role of Local VLMs in Document Processing: Our experiments with Qwen3-VL-4B-8bit highlight a crucial limitation in the current trend toward using general-purpose Vision-Language Models for specialised tasks like dense document OCR. While these models possess remarkable zero-shot capabilities, their autoregressive nature over massive context windows makes them highly inefficient for extracting dense, full-page text. The observed hallucinations and abrupt stopping are likely symptoms of the model losing its spatial grounding within the high-resolution image encoding. For tasks requiring deterministic, high-throughput text extraction, specialised architectures like PARSeq remain more practical in both speed and resource efficiency.

Threats to Validity: While the proposed pipeline demonstrates strong potential, several limitations must be acknowledged to contextualise the results fairly:

Ethical Considerations: All training corpora are used under their respective open licences. The system’s local-only design mitigates privacy risks, but any HTR technology can be misused for bulk transcription of private correspondence and should be deployed with care.

6. Conclusion

In this paper, we presented a comprehensive, end-to-end software prototype for extracting printed and handwritten Cyrillic text from documents under real constraints. By integrating advanced preprocessing treated as a configurable search space, document structure recognition, and fine-tuning the PARSeq architecture via a staged training curriculum, the system addresses several practical limitations of existing tools.

Our results indicate that specialised, lightweight architectures can outperform standard baselines like Tesseract and EasyOCR on degraded printed text, and can be more stable and resource-efficient than local VLMs for handwriting recognition. The results suggest that specialisation and careful data design can rival larger general-purpose models under strict hardware and privacy constraints.

Crucially, our experiments show that the primary barrier to further progress in Bulgarian HTR is not algorithmic but the scarcity of real-world annotated data: synthetic data cannot fully bridge the domain gap to natural handwriting. Coordinated, community-driven data collection (e.g. university-sourced essay corpora) could thus be the most impactful next step.

Use of AI Tools

During the revision of this manuscript, the authors used a general-purpose AI assistant (Anthropic’s Claude) to check the bibliography for missing fields, to normalise text formatting and correct spelling mistakes. The study’s methods, experiments, results, and conclusions are entirely the authors’ own. All AI-assisted changes were reviewed, edited, and verified by the authors, who take full responsibility for the content.

Acknowledgments

This work is partially supported by the project UNITe BG16RFPR002-1.014-0004 funded by PRIDST and EU NextGenerationEU project, through the National Recovery and Resilience Plan of the Republic of Bulgaria, project SUMMIT, No BG-RRP-2.004-0008.

Appendix A. Real-world handwritten examples

Example of real-world handwritten document from the custom test set (sample 1) Example of real-world handwritten document from the custom test set (sample 2)
Figure 6. Examples of real-world handwritten documents from the custom test set, illustrating variation in slant, stroke connection, spacing, and line regularity.

Appendix B. Detailed Dataset Composition

Table 8 provides a comprehensive breakdown of the datasets utilised for training and testing the text recognition models. The synthetic handwritten datasets were generated using custom scripts to mimic various Bulgarian cursive styles, substantially expanding the available training data for low-resource Cyrillic handwriting.

Table 8. Summary of the datasets used for training and testing the recognition models.
DatasetStyleTypeTrain. subsetTest. subset
MJSynthprintedsynthetic7,220,000892,000
OCR Cyrillic Printed 1, 9, 10printedsynthetic2,700,000300,000
BulgarianPacificohandwrittensynthetic643,36471,484
BulgarianMarckScripthandwrittensynthetic643,36471,484
BulgarianComforterhandwrittensynthetic643,36471,484
BulgarianGNUTypewriterprintedsynthetic643,36471,484
Synthetic Cyrillic Largehandwrittensynthetic3,120,000779,000
Cyrillic Handwriting Datasethandwrittenreal72,2851,543
KOHTDhandwrittenreal49,4975,500

Appendix C. Dataset Sources

Table 8 lists the datasets used in this work. The publicly available datasets can be obtained from the following sources:

The custom synthetic Bulgarian handwriting datasets generated for this work are publicly available:

Appendix D. Supported Alphabet

The system supports a carefully curated alphabet designed to handle both standard modern Bulgarian and common historical Cyrillic characters, as well as Latin fragments frequently found in administrative documents.

Table 9. The supported Latin alphabet subset.
UppercaseLowercaseUppercaseLowercaseUppercaseLowercase
AaJjSs
BbKkTt
CcLlUu
DdMmVv
EeNnWw
FfOoXx
GgPpYy
HhQqZz
IiRr
Table 10. The supported Cyrillic alphabet subset, including historical characters for archival document processing.
UppercaseLowercaseUppercaseLowercaseUppercaseLowercase
АаКкФф
БбЛлХх
ВвМмЦц
ГгНнЧч
ДдОоШш
ЕеПпЩщ
ЖжРрЪъ
ЗзСсЬь
ИиТтЮю
ЙйУуЯя
Ѣѣ
Ѩѩ

Appendix E. Table Detector Training Results

Table 11 reports training validation metrics on a 100,000-document subset of PubTables-1M (Smock et al. 2022) (8 epochs).

Table 11. Training validation metrics on a subset of PubTables-1M.
Ep.PrecisionRecallmAP50mAP50-95Val boxVal clsVal dfl
10.71820.69890.73220.58400.81860.61280.0121
20.82330.78970.82550.68910.64720.45160.0077
30.87780.82460.87240.74800.55360.37010.0060
40.91170.84480.89540.78780.48250.31320.0055
50.92600.86090.90820.81380.44570.27960.0046
60.92320.87070.91290.82540.42000.26000.0044
70.93390.87810.92070.83790.39990.24280.0041
80.93750.88210.92340.84300.39240.23310.0040

Appendix F. Training Curriculum Dataset Proportions

The four-phase curriculum learning strategy required carefully balancing the proportions of synthetic and real datasets to prevent catastrophic forgetting while adapting to new domains.

Table 12. Proportions of the training datasets across the four phases of the PARSeq training curriculum.
DatasetPhase 0Phase 1Phase 2Phase 3
MJSynth0.200.250.050.05
OCR Cyrillic Printed0.800.750.250.10
Synthetic Cyrillic Large0.300.10
BulgarianPacifico0.100.05
BulgarianMarckScript0.100.05
BulgarianComforter0.100.05
BulgarianGNUTypewriter0.100.05
Cyrillic Handwriting Dataset0.35
KOHTD0.20

Appendix G. Layout Recognition Algorithms

The system offers two interchangeable families for text detection: CRAFT (Character Region Awareness for Text Detection) and YOLO-based detectors.

CRAFT is a robust text detector that localises characters and links them into lines, which suits unconstrained layouts.

YOLO-family detectors provide fast region proposals; users can swap implementations or checkpoints as needed alongside CRAFT.

Appendix H. Training Curriculum Details

The training of the PARSeq model was conducted in four distinct phases to ensure stable convergence and prevent catastrophic forgetting. The dataset proportions, hyperparameters, and results for each phase are detailed below.

H.1. Phase 0: Alphabet Adaptation

Table 13. Proportions of the training datasets for PARSeq in Phase 0.
DatasetProportion
MJSynth0.20
OCR Cyrillic Printed0.80
Table 14. Hyperparameters for training PARSeq in Phase 0.
HyperparameterValue
Epochs2
Batch Size512
Learning Rate1×10−4
Weight Decay1×10−2
Warmup5%
Patience5
Workers8
Table 15. Results from the training of PARSeq in Phase 0.
DatasetCER (%)WER (%)
MJSynth7.9213.30
OCR Cyrillic Printed7.4023.37

H.2. Phase 1: Printed Cyrillic Stabilisation

Table 16. Proportions of the training datasets for PARSeq in Phase 1.
DatasetProportion
MJSynth0.25
OCR Cyrillic Printed0.75
Table 17. Hyperparameters for training PARSeq in Phase 1.
HyperparameterValue
Epochs10
Batch Size512
Learning Rate1×10−4
Weight Decay1×10−2
Warmup5%
Patience5
Workers8
Table 18. Results from training PARSeq in Phase 1.
DatasetCER (%)WER (%)
MJSynth4.297.74
OCR Cyrillic Printed3.1015.76

H.3. Phase 2: Handwritten Introduction

Table 19. Proportions of the training datasets for PARSeq in Phase 2.
DatasetProportion
MJSynth0.05
OCR Cyrillic Printed (1, 9, 10)0.25
Synthetic Cyrillic Large0.30
BulgarianPacifico0.10
BulgarianMarckScript0.10
BulgarianComforter0.10
BulgarianGNUTypewriter0.10
Table 20. Hyperparameters for training PARSeq in Phase 2.
HyperparameterValue
Max Epochs5
Batch Size512
Learning Rate5×10−5
Weight Decay1×10−2
Warmup5%
Patience5
Workers8
Table 21. Results from training PARSeq in Phase 2.
DatasetCER (%)WER (%)
MJSynth5.179.69
OCR Cyrillic Printed 12.699.67
OCR Cyrillic Printed 97.1048.83
OCR Cyrillic Printed 102.569.81
OCR Cyrillic Printed (concat)3.4317.02
Synthetic Cyrillic Large5.7225.74
Bulgarian Pacifico0.030.29
Bulgarian MarckScript0.020.19
Bulgarian Comforter0.040.36
Bulgarian GNU Typewriter0.030.25
Cyrillic Handwriting28.3182.42
KOHTD37.6586.58

H.4. Phase 3: Real Handwritten Adaptation

Table 22. Proportions of the training datasets for PARSeq in Phase 3.
DatasetProportion
MJSynth0.05
OCR Cyrillic Printed (1, 9, 10)0.10
Synthetic Cyrillic Large0.10
BulgarianPacifico0.05
BulgarianMarckScript0.05
BulgarianComforter0.05
BulgarianGNUTypewriter0.05
Cyrillic Handwriting Dataset0.35
KOHTD0.20
Table 23. Hyperparameters for training PARSeq in Phase 3.
HyperparameterValue
Epochs10–20
Batch Size512
Learning Rate5×10−4
Weight Decay1×10−2
Warmup5%
Patience5
Workers8
Table 24. Validation metrics from training PARSeq in Phase 3 (final).
DatasetCER (%)WER (%)
MJSynth5.5010.49
OCR Cyrillic Printed3.9817.67
Synthetic Cyrillic Large6.1327.25
Cyrillic Handwriting6.1123.92
KOHTD6.6824.87

Appendix I. Structure and Table Recognition Algorithms

For document structure recognition, we use an off-the-shelf YOLO-family layout detector (no fixed version string in our deployment) whose released weights were trained on DocLayNet (Pfitzmann et al. 2022); we did not train this module. It exposes the following classes: Caption, Footnote, Formula, List-item, Page-footer, Page-header, Picture, Section-header, Table, Text, and Title.

For tables lacking borders or complex spanning cells, we integrate a YOLO-based detector using weights trained on a subset of 100,000 documents from PubTables-1M (Smock et al. 2022) (again: third-party weights; not trained in this work).

Appendix J. Validation Metrics during Training

Figure 7Figure 11 show validation curves by training phase. Each figure stacks two plots vertically (CER on top; WER or training loss below). Phase 3 is shown twice because we validate separately on the Cyrillic Handwriting Dataset and on KOHTD.

Phase 0 (OCR Cyrillic Printed): CER (top) and training loss (bottom). (top) Phase 0 (OCR Cyrillic Printed): CER (top) and training loss (bottom). (bottom)
Figure 7. Phase 0 (OCR Cyrillic Printed): CER (top) and training loss (bottom).
Phase 1 (OCR Cyrillic Printed): CER (top) and WER (bottom). (top) Phase 1 (OCR Cyrillic Printed): CER (top) and WER (bottom). (bottom)
Figure 8. Phase 1 (OCR Cyrillic Printed): CER (top) and WER (bottom).
Phase 2 (Synthetic Cyrillic Large): CER (top) and WER (bottom). (top) Phase 2 (Synthetic Cyrillic Large): CER (top) and WER (bottom). (bottom)
Figure 9. Phase 2 (Synthetic Cyrillic Large): CER (top) and WER (bottom).
Phase 3, Cyrillic Handwriting Dataset validation split: CER (top) and WER (bottom). (top) Phase 3, Cyrillic Handwriting Dataset validation split: CER (top) and WER (bottom). (bottom)
Figure 10. Phase 3, Cyrillic Handwriting Dataset validation split: CER (top) and WER (bottom).
Phase 3, KOHTD validation split: CER (top) and WER (bottom). (top) Phase 3, KOHTD validation split: CER (top) and WER (bottom). (bottom)
Figure 11. Phase 3, KOHTD validation split: CER (top) and WER (bottom).

Appendix K. Preprocessing Effects on Printed Pages

The evaluation of individual preprocessing operations on printed test pages confirms that preprocessing should remain optional and configurable. Different algorithms address specific defects, such as blur, skew, or weak contrast.

Table 25. Representative best-case improvements from optional preprocessing on printed documents.
AlgorithmDoc.MetricBefore → After (%)
Average Filter3070-5WER35.66 → 25.19
Gaussian Filter3070-3CER11.76 → 6.49
Hough Transform16-3CER10.69 → 4.77
Projection Profile3070-4WER27.27 → 22.51
Histogram Equalisation3070-3WER31.69 → 27.46
CLAHE16-2WER21.68 → 20.28

K.1. Additional Architectural Comparisons

During the preliminary experiments, we compared the convergence and performance of several architectures before selecting PARSeq. The following figures illustrate these comparisons.

Preliminary experiments comparing PARSeq and CNN–Decoder Transformer on character error rate (CER).
Figure 12. Preliminary experiments comparing PARSeq and CNN–Decoder Transformer on character error rate (CER).
Preliminary experiments comparing CNN–Decoder Transformer and CNN–Transformer on character error rate (CER).
Figure 13. Preliminary experiments comparing CNN–Decoder Transformer and CNN–Transformer on character error rate (CER).

References

Atienza, Rowel. 2021. Vision Transformer for Fast and Efficient Scene Text Recognition. In Proceedings of the 16th International Conference on Document Analysis and Recognition (ICDAR 2021), Lausanne, Switzerland, Part I, pages 319–334. Springer.
Baek, Youngmin, Bado Lee, Dongyoon Han, Sangdoo Yun, and Hwalsuk Lee. 2019. Character region awareness for text detection. In Proceedings of the 2019 IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2019), Long Beach, CA, USA, pages 9365–9374. Computer Vision Foundation / IEEE.
Bautista, Darwin and Rowel Atienza. 2022. Scene Text Recognition with Permuted Autoregressive Sequence Models. In Proceedings of the 17th European Conference on Computer Vision (ECCV 2022), Tel Aviv, Israel, pages 178–196. Springer.
Beshirov, Angel, Milena Dobreva, Dimitar Dimitrov, Momchil Hardalov, Ivan Koychev, and Preslav Nakov. 2025. Post-OCR Text Correction for Bulgarian Historical Documents. International Journal on Digital Libraries 26 (4).
Dosovitskiy, Alexey, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. 2021. An Image is Worth 16×16 Words: Transformers for Image Recognition at Scale. In Proceedings of the 9th International Conference on Learning Representations (ICLR 2021), Virtual Event, Austria.
Ester, Martin, Hans-Peter Kriegel, Jörg Sander, and Xiaowei Xu. 1996. A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD-96), Portland, Oregon, USA, pages 226–231. AAAI Press.
Fang, Shancheng, Hongtao Xie, Yuxin Wang, Zhendong Mao, and Yongdong Zhang. 2021. Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition. In Proceedings of the 2021 IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2021), pages 7098–7107. Computer Vision Foundation / IEEE.
Graves, Alex, Santiago Fernández, Faustino Gomez, and Jürgen Schmidhuber. 2006. Connectionist temporal classification: labelling unsegmented sequence data with recurrent neural networks. In Proceedings of the 23rd International Conference on Machine Learning, pages 369–376. New York, NY, USA: Association for Computing Machinery.
Jaderberg, Max, Karen Simonyan, Andrea Vedaldi, and Andrew Zisserman. 2014. Synthetic data and artificial neural networks for natural scene text recognition. In Proceedings of the Workshop on Deep Learning (NIPS).
Jocher, Glenn, Ayush Chaurasia, and Jing Qiu. 2024. YOLO by Ultralytics. GitHub. https://github.com/ultralytics/ultralytics.
Kittinaradorn, Rakpong et al. 2020. EasyOCR. Jaided AI. https://github.com/JaidedAI/EasyOCR.
Kostov, Nikolay. 2011. Analiz na balgarskiya ezik chrez Wikipedia (in Bulgarian). https://nikolay.it/Blog/2011/08/%D0%90%D0%BD%D0%B0%D0%BB%D0%B8%D0%B7-%D0%BD%D0%B0-%D0%B1%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8%D1%8F-%D0%B5%D0%B7%D0%B8%D0%BA-%D1%87%D1%80%D0%B5%D0%B7-Wikipedia/3.
Kratchanov, Ivan, Laska Laskova, and Kiril Simov. 2020. Towards Improving OCR Accuracy with Bulgarian Language Resources. In Proceedings of Twin Talks 3: Understanding and Facilitating Collaboration in Digital Humanities (DH 2020), pages 115–123.
Li, Minghao, Tengchao Lv, Jingye Chen, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, and Furu Wei. 2022. TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models. arXiv, abs/2109.10282. https://arxiv.org/abs/2109.10282.
Pfitzmann, Birgit, Christoph Auer, Michele Dolfi, Ahmed S. Nassar, and Peter W. J. Staar. 2022. DocLayNet: A Large Human-Annotated Dataset for Document-Layout Segmentation. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD 2022), Washington, DC, USA, pages 3743–3751. ACM.
PUMB AI. 2024. Synthetic Cyrillic Large. Hugging Face. Apache-2.0 license. https://huggingface.co/datasets/pumb-ai/synthetic-cyrillic-large.
Qwen Team. 2025. Qwen3-VL Technical Report. arXiv, abs/2511.21631. https://arxiv.org/abs/2511.21631.
Shi, Baoguang, Xiang Bai, and Cong Yao. 2017. An End-to-End Trainable Neural Network for Image-Based Sequence Recognition and Its Application to Scene Text Recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence 39 (11): 2298–2304.
Smith, Ray. 2007. An overview of the Tesseract OCR engine. In Proceedings of the International Conference on Document Analysis and Recognition (ICDAR 2007), Curitiba, Paraná, Brazil, pages 629–633.
Smock, Brandon, Rohith Pesala, and Robin Abraham. 2022. PubTables-1M: Towards comprehensive table extraction from unstructured documents. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR 2022), New Orleans, LA, USA, pages 4634–4642. IEEE.
Toiganbayeva, Nazgul, Mahmoud Kasem, Galymzhan Abdimanap, Kairat Bostanbekov, Abdelrahman Abdallah, Anel Alimova, and Daniyar Nurseitov. 2022. KOHTD: Kazakh offline handwritten text dataset. Signal Processing: Image Communication: 116827.
Ultralytics. 2023. Ultralytics YOLO. GitHub. https://github.com/ultralytics/ultralytics.
Werner, Constantin. 2021. Cyrillic Handwriting Dataset. Kaggle. https://www.kaggle.com/datasets/constantinwerner/cyrillic-handwriting-dataset.
Zhu, Xizhou, Han Hu, Stephen Lin, and Jifeng Dai. 2018. Deformable ConvNets v2: More Deformable, Better Results. arXiv, abs/1811.11168. https://arxiv.org/abs/1811.11168.