All models

vision-encoder-decoder (image text to text)

An image-to-text model that pairs a Transformer vision encoder with an autoregressive language model decoder.

Multimodal · 915 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (59 KB)

Open in a new tab

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.

At a glance

Parameters
224.3M
Operations
915
Framework
PyTorch
Recurrent
No
Published
AAAI (arXiv 2021)
Cited by
596 (as of 23 October 2026)
Authors
Minghao Li, Tengchao Lv, Jingye Chen and others
Name in source
vision-encoder-decoder:image-text-to-text
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m10913
Graph hash
b2c25b223792ab699e2e9220dff0d162614292691469928680ffcdbc7baa52fb
Skeleton hash
eaa4f98eb7fffd8e26570ba6beb15ec7539d7f3b1456a2a23f416cf22a88d881
Architecture hash
6d74bbd34d59909d8aff74ad7b5fc9e30db98b9bc68445d5c44b4e2524831888
Diagram SHA-256
b1269101ac6cfca16860ce2420c1a2f723d0cc039d18bac2599b8a59f92e4fed
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

VisionEncoderDecoderModel is a general image-to-text architecture in the Transformers library: a Transformer-based vision model is the encoder and a language model is the decoder. The vision side can be a model such as ViT, BEiT, DeiT or Swin, and the text side a model such as RoBERTa, GPT2, BERT or DistilBERT.

In image captioning, for example, the encoder encodes the image and an autoregressive language model then generates the caption; optical character recognition is the other application the library names. When the model is assembled from a pretrained encoder and a pretrained decoder, the cross-attention layers might be randomly initialized, depending on the decoder, so it has to be fine-tuned on a downstream task. Training needs only two inputs to compute a loss: the images and the token ids of the target text.

The idea of initializing image-to-text models from pretrained checkpoints was shown to work in the TrOCR paper, and TrOCR is an instance of VisionEncoderDecoderModel. TrOCR is an end-to-end text recognition approach built from pre-trained image Transformer and text Transformer models, which its paper reports outperformed the models it was compared with on printed, handwritten and scene text recognition tasks. In TrOCR the encoder can be initialized with pre-trained ViT-style models and the decoder with pre-trained BERT-style models.

Key idea. VisionEncoderDecoderModel combines any pretrained Transformer-based vision encoder with any pretrained language model decoder to form an image-to-text model, an approach TrOCR showed effective for text recognition.

  • vision encoder decoder
  • visionencoderdecodermodel
  • vision-encoder-decoder
  • image-to-text
  • image captioning
  • optical character recognition
  • ocr
  • encoder-decoder transformer

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@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}, 
}