Roboflow

TrOCR Overview

TrOCR (Transformer-based Optical Character Recognition) is an end-to-end OCR model released in September 2021 by Microsoft Research. It departs from the traditional two-stage OCR pipeline — which typically combines a CNN-based feature extractor with an RNN-based sequence decoder — by using a pure Transformer architecture composed of a pretrained image Transformer encoder and a pretrained text Transformer decoder, an approach that later became standardized as the VisionEncoderDecoder pattern in Hugging Face Transformers.

TrOCR takes a cropped text line image as input and produces a sequence of output tokens, supporting printed, handwritten, and scene text recognition. The model is designed for use downstream of a separate text detection stage — TrOCR recognizes text in pre-cropped regions rather than detecting text locations in a full page. Microsoft released three size variants: TrOCR-small (62M parameters, DeiT-small encoder + MiniLM decoder), TrOCR-base (334M parameters, BEiT-base encoder + RoBERTa-large decoder), and TrOCR-large (558M parameters, BEiT-large encoder + RoBERTa-large decoder). Pretrained and fine-tuned checkpoints are available for printed text (on SROIE), handwritten text (on IAM), and scene text (on the standard scene text benchmarks) under the MIT license, distributed through the Microsoft unilm repository and Hugging Face. At release, TrOCR achieved state-of-the-art results across all three benchmark categories, and the model continues to be used as a baseline for handwritten text recognition.

TrOCR Details & Performance

Details

Resources

Vision Tasks

OCR

Features

Usage

Past 30 Days

Not available

Not in Playground

Performance

Avg. Latency

Arena Rankings

Not yet ranked in arena

TrOCR Vision Evals

HighestLowest
This model#53 of 5526.2% pass rate · better than 4%
Score26.2%pass rate across 229 tasks
Speed0.28savg response per task
Costpricing unavailable
Tokenstokens unavailable
Score key:≥75%40–74%<40%
CategoryPassedScore
Text Recognition16 / 30
53.3%
Focused Scene OCR34 / 99
34.3%
License Plate Recognition10 / 30
33.3%
VQA & Extraction0 / 60
0%
Handwritten Math0 / 10
0%

Scores based on a single evaluation run · Methodology

View all Vision Evals →

Price vs. performance

Estimated cost per task vs. OCR score, for this model and others ranked near it. Upper-left is the sweet spot (high quality, low cost).

6 of 7 models plotted · 1 not yet evaluated

ModelScoreMedian tokensEst. cost / taskCompare
AnthropicClaude Sonnet 4.567.3%866$0.0039Compare
GoogleGemma 3 4B64.2%314<$0.0001Compare
OpenAIGPT-5.4 Nano62.5%294$0.0001Compare
AnthropicClaude Haiku 4.561.6%861$0.0012Compare
QwenQwen3.6 Plus58.5%166$0.0001Compare
AzureTrOCR(this model)26.2%
MoonshotAIKimi K2.519.6%706$0.0006Compare

Alternatives to TrOCR

Other models worth comparing for similar use cases.

Azure
Florence-2
Florence-2, introduced by Microsoft Research at CVPR 2024, is an open-source vision-language foundation model designed to unify diverse computer vision tasks within a single sequence-to-sequence framework. Unlike traditional models that specialize in specific tasks, Florence-2 accepts both images and text prompts and outputs text for tasks such as captioning, object detection, segmentation, OCR, and region-based grounding. It comes in two sizes—Florence-2-base (~230M parameters) and Florence-2-large (~770M parameters)—and is trained on FLD-5B, a large dataset of ~126M images with ~5.4B annotations.The model demonstrates strong zero-shot and fine-tuned performance, often rivaling larger vision-language systems while remaining lightweight and efficient. Released under the MIT license, all weights are publicly available, making it accessible for fine-tuning and deployment in applications like VQA, content tagging, accessibility, and research. Florence-2’s compact design, versatility, and openness position it as a practical alternative to larger proprietary multimodal models.
docTR
docTR (Document Text Recognition) is an open-source OCR toolkit developed by Mindee, with its initial public release in March 2021 under the Apache 2.0 license. It provides end-to-end document text recognition through a two-stage pipeline consisting of text detection and text recognition, both implemented as deep learning models. docTR supports multiple detection architectures including DBNet and LinkNet, and recognition architectures including CRNN and SAR, with both TensorFlow and PyTorch backends available.docTR is designed for reading text in document images including scanned PDFs, photographs of printed documents, and forms. It handles multilingual text recognition across standard Latin-script languages and is deployable through Roboflow Inference. It is suited for document digitization pipelines, automated form processing, and applications requiring accurate structured text extraction from document images.
Surya
Surya is an OCR and document layout analysis toolkit developed by Vikram Paruchuri and distributed via Mindee, first released in January 2024 under the GPL-3.0 license. It supports text recognition across more than 90 languages, document layout detection, reading order prediction, table recognition, and equation detection, providing a comprehensive set of tools for extracting structured information from document images.Surya is designed to operate without cloud API dependencies, running fully on local hardware with support for CPU and GPU inference. It is commonly used for digitizing scanned documents, extracting text from PDFs with complex layouts, and building automated document processing pipelines.
Google
PaliGemma 2
PaliGemma 2 is a vision-language model released in December 2024 by Google DeepMind. It pairs the SigLIP-So400m vision encoder with the Gemma 2 language model family, extending the original PaliGemma architecture with stronger language capabilities and a wider set of transfer benchmarks. The model is designed primarily as a fine-tuning base rather than a chat-optimized assistant. Google releases pretrained "PT" checkpoints intended for task-specific adaptation rather than direct out-of-the-box use.PaliGemma 2 accepts an image paired with a text prompt and generates natural language output, supporting image captioning, visual question answering, optical character recognition, document understanding, object detection and segmentation (with appropriate fine-tuning), and a range of specialized vision-language tasks. The model is released at three parameter sizes (3B, 10B, and 28B), built on the Gemma 2 2B, 9B, and 27B language backbones. Each size is available at three input resolutions: 224, 448, and 896 pixels. Alongside the base PT checkpoints, Google released PaliGemma 2 Mix variants that have been tuned on a mixture of downstream tasks to provide stronger out-of-the-box performance for common applications such as OCR and document parsing. PaliGemma 2 is distributed under the Gemma license, a custom license from Google that permits commercial use subject to the terms of the Gemma Prohibited Use Policy.
Z.ai
GLM-OCR
GLM-OCR is a multimodal OCR model for complex document understanding, built on the GLM-V encoder-decoder architecture by Zhipu AI. The model combines a 0.4B-parameter CogViT visual encoder pre-trained on large-scale image-text data, a lightweight cross-modal connector with efficient token downsampling, and a 0.5B-parameter GLM language decoder, totaling 0.9B parameters. To address the inefficiency of standard autoregressive decoding in deterministic OCR tasks, GLM-OCR introduces a Multi-Token Prediction (MTP) mechanism that predicts multiple tokens per step, significantly improving decoding throughput while keeping memory overhead low through shared parameters. Training proceeds through four stages: visual encoder pretraining with MIM, CLIP, and distillation objectives; vision-language pretraining on document parsing, grounding, and VQA data; supervised fine-tuning on curated OCR datasets covering text, formula, table, and key information extraction; and full-task reinforcement learning to improve accuracy and structural consistency.At the system level, GLM-OCR adopts a two-stage pipeline in which PP-DocLayout-V3 first performs layout analysis, followed by parallel region-level recognition. This design enables robust handling of diverse document layouts including tables, formulas, and multi-column text. The model supports document parsing and targeted recognition tasks, producing structured outputs in Markdown, JSON, and LaTeX formats across more than 100 languages. On the OmniDocBench V1.5 benchmark, GLM-OCR scores 94.62, and achieves 94.0 on OCRBench and 96.5 on UniMERNet for formula recognition.
Google
Gemini 2.5 Flash-Lite
Gemini 2.5 Flash-Lite, released for general availability on July 22, 2025, is the most cost-efficient model in the Gemini 2.5 family, designed for high-volume and latency-sensitive tasks. It is multimodal, supporting text, images, video, audio, and PDFs as inputs, with text as its primary output. The model handles up to 1 million input tokens and generates outputs up to 64K tokens, making it suitable for large-scale document or media processing at low cost. It is built on a Sparse Mixture-of-Experts architecture with native multimodal support, though exact parameter counts are undisclosed.Flash-Lite offers the lowest usage cost among Gemini 2.5 models. It introduces developer controls for “thinking mode,” allowing fine-tuning of reasoning depth vs. efficiency. It also integrates native tools such as code execution, search grounding, and URL context. While strong on translation, classification, coding, and general multimodal reasoning, it lacks support for image or audio generation in its stable release and is less capable than Gemini 2.5 Flash or Pro on complex reasoning-heavy workflows.

TrOCR License

MIT

License terms and commercial-use guidance for TrOCR.

License information is provided as a guide and is not legal advice.