DLoRA-TrOCR: Mixed Text Mode Optical Character Recognition Based On Transformer

Da Chang, Yu LiarXiv 2024 · DOI · arXiv

Abstract

DLoRA-TrOCR is an efficient approach for recognizing mixed-scene text—including handwritten, printed, and street view imagery—by applying a hybrid parameter-efficient fine-tuning (PEFT) strategy to the TrOCR architecture. By utilizing Weight-Decomposed Low-Rank Adaptation (DoRA) for the image encoder and standard Low-Rank Adaptation (LoRA) for the text decoder, the model achieves state-of-the-art performance while training fewer than 0.7% of the total parameters. This hybrid strategy effectively addresses the high variance in visual features across different text domains while significantly reducing computational overhead.

Introduction

Traditional Optical Character Recognition (OCR) systems are often specialized for specific domains, such as neat printed documents or messy handwriting. Developing a universal model for "mixed-scene" text is challenging due to the diverse visual profiles and noise levels inherent in these categories. Furthermore, full-parameter fine-tuning of large Transformer models like TrOCR is computationally prohibitive and prone to "catastrophic forgetting," where the model loses general pre-trained knowledge while learning a niche task. DLoRA-TrOCR overcomes these hurdles by employing a targeted PEFT approach that optimizes only a small fraction of the model's weights.

Methodology

The researchers built their solution on the TrOCR framework, which utilizes a Vision Transformer (ViT) encoder and a RoBERTa-based language model decoder. The core of the methodology is the hybrid PEFT strategy designed to optimize different components of the architecture based on their specific roles.

Hybrid PEFT Architecture

The model applies distinct adaptation techniques to the encoder and decoder:

  • DoRA for the Encoder: DoRA decomposes weights into magnitude and direction components. This is particularly effective for the vision encoder as it helps the model better distinguish text from complex backgrounds and noise in scene and handwritten images.
  • LoRA for the Decoder: Standard LoRA is used for the text decoder. Since the pre-trained language model is already robust at sequence prediction, a lighter adaptation via low-rank matrices in the attention layers is sufficient.
The DLoRA-TrOCR architecture, illustrating the integration of DoRA in the encoder and LoRA in the decoder.

Weight Decomposition (DoRA)

The application of DoRA in the encoder is a key technical innovation. By decomposing the weight updates, the model achieves more stable learning in the high-variance visual domain compared to standard LoRA.

Detailed mechanism of Weight-Decomposed Low-Rank Adaptation (DoRA) used to stabilize directional updates in the encoder.

Experimental Results

DLoRA-TrOCR was evaluated across handwritten (IAM), printed (SROIE), and scene text (STR) datasets to test its general robustness.

Performance and Efficiency

  • Accuracy: The model achieved a Character Error Rate (CER) of 4.02 on the IAM dataset and an F1 score of 94.29 on SROIE, outperforming full-parameter fine-tuning in several categories.
  • Parameter Efficiency: Only ~2.0M parameters (0.594% of the total 333.9M) are trained. This results in a 30% reduction in GPU memory usage during training.
  • Inference: The model maintains a high inference speed of approximately 656 tokens/s.

Key Insights

Ablation studies revealed that fine-tuning the image encoder is significantly more critical for OCR performance than fine-tuning the decoder. In fact, over-tuning the decoder on small datasets can diminish generalization. Additionally, the scaling factor (alpha) in the adaptation layers was found to be more influential than the rank (r), suggesting that the magnitude of learned updates is more important than the dimensionality of the low-rank space.

Conclusion

DLoRA-TrOCR provides a highly efficient and effective blueprint for mixed-mode OCR. By tailoring PEFT methods to specific architectural components, the model achieves state-of-the-art results with minimal computational resources. Future work will explore extending this hybrid approach to multi-lingual OCR and other vision-language tasks such as image captioning and Document Visual Question Answering (DocVQA).

Summary updated

BibTeX
@misc{chang2024dlora,
  author = {Da Chang and Yu Li},
  title = {{DLoRA-TrOCR: Mixed Text Mode Optical Character Recognition Based On Transformer}},
  year = {2024},
  eprint = {2404.12734},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.12734},
}
Figure