SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.10282 · 2021

TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2109.10282.json · badge: /api/ran/2109.10282.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
oleehyo/texteller community (classifier label)
classifier basis not recorded on the link
4 ran · 1 no recorded run
d-gurgurov/im2latex community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
FunctionStatusWhere it lives
contains_ignore_begin Ran
ran on a synthesized input
oleehyo/texteller/texteller/api/format.py
code served (permissive licence) · get_code("ddd787523c07e485")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for contains_ignore_begin function

ARGS = {
    "line": "some text % tex-fmt: off"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
contains_ignore_skip Ran
ran on a synthesized input
oleehyo/texteller/texteller/api/format.py
code served (permissive licence) · get_code("59b0d21e9bd0149a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for contains_ignore_skip function

ARGS = {
    "line": "some code here % tex-fmt: skip"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
filter_dataset Ran
ran on a synthesized input
d-gurgurov/im2latex/src/im2latex_finetune_handwritten.py
code served (permissive licence) · get_code("e06ee9353a478f82")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned MockDataset. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create a minimal dataset-like object that has a filter method
class MockDataset:
    def __init__(self, samples):
        self.samples = samples
    
    def filter(self, is_valid_fn):
        """Filter samples using the provided function"""
        filtered = [s for s in self.samples if is_valid_fn(s)]
        return MockDataset(filtered)

# Create valid samples with required 'image' and 'text' keys
valid_samples = [
    {
        'image': torch.randn(3, 4),  # dummy image tensor
        'text': 'x^2 + y^2 = z^2'    # valid latex string
    },
    {
        'image': torch.randn(3, 4),
        'text': 'e^{i\\pi} + 1 = 0'
    },
    {
        'image': torch.randn(3, 4),
        'text': '\\frac{1}{2}'
    }
]

# Create invalid samples to test filtering
invalid_samples = [
    {
        'image': None,
        'text': 'some latex'
    },
    {
        'image': torch.randn(3, 4),
        'text': None
    },
    {
        'image': torch.randn(3, 4),
        'text': ''  # empty string
    },
    {
        'image': torch.randn(3, 4)
        # missing 'text' key
    }
]

# Combine valid and invalid samples
all_samples = valid_samples + invalid_samples
dataset = MockDataset(all_samples)

ARGS = {
    'dataset': dataset
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockDataset — a MockDataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockDataset output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_comment_index Ran
ran on a synthesized input
oleehyo/texteller/texteller/api/format.py
code served (permissive licence) · get_code("fad68f0fdc560775")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re
from dataclasses import dataclass
from typing import List, Optional, Tuple

ITEM = '\\item'

ENV_BEGIN = '\\begin{'

ENV_END = '\\end{'

SPLITTING = ['\\\\begin\\{', '\\\\end\\{', '\\\\item(?:$|[^a-zA-Z])', '\\\\(?:sub){0,2}section\\*?\\{', '\\\\chapter\\*?\\{', '\\\\part\\*?\\{']

SPLITTING_STRING = f"({'|'.join(SPLITTING)})"

RE_SPLITTING = re.compile(SPLITTING_STRING)

@dataclass
class Pattern:
    """Record whether a line contains certain patterns."""
    contains_env_begin: bool = False
    contains_env_end: bool = False
    contains_item: bool = False
    contains_splitting: bool = False
    contains_comment: bool = False

    @classmethod
    def new(cls, s: str):
        """Check if a string contains patterns."""
        if RE_SPLITTING.search(s):
            return cls(contains_env_begin=ENV_BEGIN in s, contains_env_end=ENV_END in s, contains_item=ITEM in s, contains_splitting=True, contains_comment='%' in s)
        else:
            return cls(contains_env_begin=False, contains_env_end=False, contains_item=False, contains_splitting=False, contains_comment='%' in s)

def find_comment_index(line: str, pattern: Pattern) -> Optional[int]:
    """Find the index of a comment in a line."""
    if not pattern.contains_comment:
        return None
    in_command = False
    for i, c in enumerate(line):
        if c == '\\':
            in_command = True
        elif in_command and (not c.isalpha()):
            in_command = False
        elif c == '%' and (not in_command):
            return i
    return None


# Test case 1: line with comment, pattern indicates comment exists
line_with_comment = "Some text here % this is a comment"
pattern_with_comment = Pattern(contains_comment=True)

# Test case 2: line without comment
line_without_comment = "Some text here without comment"
pattern_without_comment = Pattern(contains_comment=False)

# Test case 3: line with escaped percent and real comment
line_with_escaped = "Text with \\% escaped and real % comment here"
pattern_with_escaped = Pattern(contains_comment=True)

ARGS = {
    "line": line_with_comment,
    "pattern": pattern_with_comment
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
transform Ran
ran on a synthesized input
oleehyo/texteller/texteller/paddleocr/predict_det.py
code served (permissive licence) · get_code("064afdff91999507")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Define some simple callable operations that transform data
class AddOneOp:
    def __call__(self, data):
        if isinstance(data, torch.Tensor):
            return data + 1
        return data

class MultiplyOp:
    def __call__(self, data):
        if isinstance(data, torch.Tensor):
            return data * 2
        return data

class NoneReturningOp:
    def __call__(self, data):
        return None

# Create sample data: a small tensor
sample_data = torch.randn(2, 4)

# Create list of operations
ops_list = [AddOneOp(), MultiplyOp()]

# Alternative ops list that returns None partway through
ops_with_none = [AddOneOp(), NoneReturningOp()]

# Alternative empty ops list
ops_empty = []

ARGS = {
    "data": sample_data,
    "ops": ops_list
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
to_katex Not yet run
unverified (harvested, no recorded run)
oleehyo/texteller/texteller/api/katex.py
code served (permissive licence) · get_code("8560b82a7e0c9ba0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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}.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2109.10282")
get_code_for_paper("2109.10282")
have("2109.10282")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2109.10282.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2109.10282.svg)](https://syntology.ai/paper/2109.10282)

Connect an agent — have() is free.