DTrOCR-Base
Patches in, characters out, with nothing but a GPT-2 style decoder in between.
Documents and OCR · 493 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.
At a glance
- Task
- Documents and OCR
- Parameters
- 162.7M
- Operations
- 493
- Framework
- PyTorch
- Recurrent
- No
- Published
- WACV 2024
- Cited by
- 3 (as of 16 October 2026)
- Authors
- Masato Fujitake
- Source
- GitHub: arvindrajan92/DTrOCR
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
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.
Details
- Stable ID
- m587
- Graph hash
- 230627fc7c88c2b3846d4ad3565a0e6fb8f0f11904887ee6b10830483a69d5c1
- Skeleton hash
- 9c3d8ccc7ad7da775a1551ded04cd7ed511e0a3b8dffbeaf0b1f2e2b3d406454
- Architecture hash
- 91d7bfb2531a73a4d72190012775b6ece629b023de0d20edb54311f3ccc1883c
- Diagram SHA-256
- 42e9859a707cb7a39545f80075dbae0eeace4355609616c9aafbfcc80126a08e
- 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
DTrOCR is a text recogniser with no vision encoder at all: the image is cut into patches and fed, with the text, into a single decoder-only Transformer borrowed from a pretrained generative language model. The paper frames this against the usual encoder-decoder design, where an encoder extracts image features and a decoder turns them into text. The question being tested is whether a language model that worked in natural language processing can also read images.
The model has two parts, a patch embedding and a Transformer decoder. The image is divided into fixed-size patches, each turned into a vector with position encoding added, and the resulting sequence goes to the decoder. A special separator token marks the boundary between image and text, after which the decoder predicts tokens autoregressively until the end token. Each decoder block is a masked multi-head self-attention plus a feed-forward network, and because there is no encoder there is no cross-attention between image features and text. The published configuration is the English and Chinese GPT-2 models with 12 layers, 768 hidden dimensions and 12 heads, with 8 by 4 image patches and a maximum token length of 512.
The traced code is an independent PyTorch implementation whose authors are not affiliated with the paper's author, built from the published description. Its pre-trained weights were not available at the time of the saved README, which also lists English only and a 256 token maximum as its departures from the paper. The paper reports that DTrOCR outperforms prior methods by a large margin on printed, handwritten and scene text in English and Chinese.
Key idea. DTrOCR drops the vision encoder and reads text images with a decoder-only Transformer initialised from a pretrained generative language model.
- DTrOCR
- Decoder-only Transformer for Optical Character Recognition
- OCR
- text recognition
- scene text
- handwriting recognition
- GPT-2
- decoder-only transformer
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{fujitake2023dtrocrdecoderonlytransformeroptical,
title={DTrOCR: Decoder-only Transformer for Optical Character Recognition},
author={Masato Fujitake},
year={2023},
eprint={2308.15996},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2308.15996},
}