{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/trocr-transformer-based-optical-character","title":"TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models","arxiv_id":"2109.10282","date":"2021-09-21","proceeding":null,"authors":["Minghao Li","Tengchao Lv","Jingye Chen","Lei Cui","Yijuan Lu","Dinei Florencio","Cha Zhang","Zhoujun Li","Furu Wei"],"abstract":"Text recognition is a long-standing research problem for document digitalization. Existing approaches are usually built based on CNN for image understanding and RNN for char-level text generation. In addition, another language model is usually needed to improve the overall accuracy as a post-processing step. In this paper, we propose an end-to-end text recognition approach with pre-trained image Transformer and text Transformer models, namely TrOCR, which leverages the Transformer architecture for both image understanding and wordpiece-level text generation. The TrOCR model is simple but effective, and can be pre-trained with large-scale synthetic data and fine-tuned with human-labeled datasets. Experiments show that the TrOCR model outperforms the current state-of-the-art models on the printed, handwritten and scene text recognition tasks. The TrOCR models and code are publicly available at \\url{https://aka.ms/trocr}.","url_abs":"https://arxiv.org/abs/2109.10282v5","url_pdf":"https://arxiv.org/pdf/2109.10282v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/microsoft/unilm/tree/master/trocr","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/d-gurgurov/im2latex","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/huggingface/transformers","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/oleehyo/texteller","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"paddle","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/MindCode-4/code-5/tree/main/trocr","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/prathameshza/TrOCR_FineTuning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/pwc-1/Paper-10/tree/main/trocr","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"trocr-transformer-based-optical-character","repo_url":"https://github.com/pwc-1/Paper-9/tree/main/1/trocr","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[{"task_slug":"handwritten-text-recognition","task_name":"Handwritten Text Recognition"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"optical-character-recognition","task_name":"Optical Character Recognition"},{"task_slug":"optical-character-recognition","task_name":"Optical Character Recognition (OCR)"},{"task_slug":"scene-text-recognition","task_name":"Scene Text Recognition"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"trocr","method_name":"TrOCR"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[{"slug":"trocr","name":"TrOCR","full_name":"TrOCR"}],"results":[{"leaderboard":"/sota/handwritten-text-recognition-on-iam","task":"Handwritten Text Recognition","dataset":"IAM","model":"TrOCR-large 558M","rank_in_archive_order":3,"of":17,"metrics":{"CER":"2.89"},"uses_additional_data":false},{"leaderboard":"/sota/handwritten-text-recognition-on-iam","task":"Handwritten Text Recognition","dataset":"IAM","model":"TrOCR-base 334M","rank_in_archive_order":5,"of":17,"metrics":{"CER":"3.42"},"uses_additional_data":false},{"leaderboard":"/sota/handwritten-text-recognition-on-iam","task":"Handwritten Text Recognition","dataset":"IAM","model":"TrOCR-small 62M","rank_in_archive_order":6,"of":17,"metrics":{"CER":"4.22"},"uses_additional_data":false},{"leaderboard":"/sota/handwritten-text-recognition-on-iam-line","task":"Handwritten Text Recognition","dataset":"IAM(line-level)","model":"TrOCR","rank_in_archive_order":1,"of":5,"metrics":{"Test CER":"3.4","Test WER":"-"},"uses_additional_data":true},{"leaderboard":"/sota/handwritten-text-recognition-on-lam-line","task":"Handwritten Text Recognition","dataset":"LAM(line-level)","model":"TrOCR","rank_in_archive_order":5,"of":6,"metrics":{"Test CER":"3.6","Test WER":"11.6"},"uses_additional_data":true}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2109.10282","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2109.10282"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/huggingface/transformers","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/oleehyo/texteller","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pwc-1/Paper-10/tree/main/trocr","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pwc-1/Paper-9/tree/main/1/trocr","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/microsoft/unilm/tree/master/trocr","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindCode-4/code-5/tree/main/trocr","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/d-gurgurov/im2latex","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/prathameshza/TrOCR_FineTuning","reach":{"status":"ok"}}],"summary":{"unverified":6},"by_repo_kind":{"listed":{"samples":6,"ran":0,"repositories":2}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"ddd787523c07e485","entry":"contains_ignore_begin","repo":"oleehyo/texteller","repo_kind":"listed","path":"texteller/api/format.py","file_url":"https://github.com/oleehyo/texteller/blob/HEAD/texteller/api/format.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ddd787523c07e485"}},{"code_sha256_prefix":"59b0d21e9bd0149a","entry":"contains_ignore_skip","repo":"oleehyo/texteller","repo_kind":"listed","path":"texteller/api/format.py","file_url":"https://github.com/oleehyo/texteller/blob/HEAD/texteller/api/format.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"59b0d21e9bd0149a"}},{"code_sha256_prefix":"e06ee9353a478f82","entry":"filter_dataset","repo":"d-gurgurov/im2latex","repo_kind":"listed","path":"src/im2latex_finetune_handwritten.py","file_url":"https://github.com/d-gurgurov/im2latex/blob/HEAD/src/im2latex_finetune_handwritten.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e06ee9353a478f82"}},{"code_sha256_prefix":"fad68f0fdc560775","entry":"find_comment_index","repo":"oleehyo/texteller","repo_kind":"listed","path":"texteller/api/format.py","file_url":"https://github.com/oleehyo/texteller/blob/HEAD/texteller/api/format.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fad68f0fdc560775"}},{"code_sha256_prefix":"8560b82a7e0c9ba0","entry":"to_katex","repo":"oleehyo/texteller","repo_kind":"listed","path":"texteller/api/katex.py","file_url":"https://github.com/oleehyo/texteller/blob/HEAD/texteller/api/katex.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8560b82a7e0c9ba0"}},{"code_sha256_prefix":"064afdff91999507","entry":"transform","repo":"oleehyo/texteller","repo_kind":"listed","path":"texteller/paddleocr/predict_det.py","file_url":"https://github.com/oleehyo/texteller/blob/HEAD/texteller/paddleocr/predict_det.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"064afdff91999507"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}