
TrOCR-Base-EncoderDecoder
Documents and OCR1,041 ops333.9M params
An encoder-decoder Transformer that reads a text-line image as patches and writes out the text token by token.
Documents and OCR · 682 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
TrOCR-Small pairs the DeiT-small encoder with a decoder initialized from MiniLM; the paper reports 62M total parameters for this setting. Because its encoder is initialized from DeiT, the input sequence keeps DeiT's distillation token.
About this model's family
TrOCR is a text recognition model that turns an image of a line of text into the text itself, using a Transformer for both the image and the language side. The paper sets this against existing approaches, which it describes as usually built on a CNN for image understanding and an RNN for text generation. TrOCR has no CNN backbone: the input image is resized to 384×384 and split into a sequence of 16×16 patches for the image Transformer. The decoder then generates the recognized text as wordpiece units.
Both halves start from existing pre-trained models, and the authors describe the paper as, to their knowledge, the first work to jointly use pre-trained image and text Transformers for text recognition in OCR. Encoders are initialized from DeiT and BEiT models. Decoders are initialized from RoBERTa and MiniLM models. Those are encoder-only models, so the encoder-decoder attention layers have no counterpart in them and the absent parameters are randomly initialized.
Pre-training runs in two stages, the first on a synthesized dataset of printed text lines that the paper puts at 684M. On the SROIE receipt dataset, the paper's results table lists word-level F1 of 95.82 for TrOCR-Small and 96.34 for TrOCR-Base.
Key idea. TrOCR is an end-to-end text recognition approach built from a pre-trained image Transformer and a pre-trained text Transformer.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{li2022trocrtransformerbasedopticalcharacter,
title={TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
author={Minghao Li and Tengchao Lv and Jingye Chen and Lei Cui and Yijuan Lu and Dinei Florencio and Cha Zhang and Zhoujun Li and Furu Wei},
year={2022},
eprint={2109.10282},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2109.10282},
}