Skip to content
ModelListedExternal
Download

Trocr Finetuned Typewritten

A fine-tuned version of microsoft/trocr-base-printed optimized for typewritten historical documents, specifically U.S. County deed record indices.

KindText modelBase modelmicrosoft/trocr-base-printedVersionmodel

Model source

Kind
Text model
File size
1.24 GB
Base model
microsoft/trocr-base-printed
Version
vmodel
Updated
Sep 17, 2026
Downloads
0
Tasks
Captioning
Source
Hugging Face

Source description

TrOCR Fine-tuned for Typewritten Text

A fine-tuned version of microsoft/trocr-base-printed optimized for typewritten historical documents, specifically U.S. County deed record indices.

Model Description

  • Base Model: microsoft/trocr-base-printed
  • License: MIT
  • Task: Optical Character Recognition (OCR) for typewritten text

This model was fine-tuned on 8,100 manually annotated images of typewritten index entries from historical deed records. It achieves near-perfect accuracy on this domain, with an exact match rate of 99.88%.

Intended Use

Primary use case: OCR for typewritten documents, particularly historical records with similar formatting to mid-20th century U.S. county indices.

Limitations: This model was trained on a specific document style. Performance on handwritten text, modern fonts, or significantly different layouts has not been evaluated and may be poor.

Segment Example

Usage

from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image

processor = TrOCRProcessor.from_pretrained("m-mjm/trocr-finetuned-typewritten")
model = VisionEncoderDecoderModel.from_pretrained("m-mjm/trocr-finetuned-typewritten")

# Load image (ensure this is a crop of a text line, not a full page)
image = Image.open("your_image.ext").convert("RGB")
pixel_values = processor(images=image, return_tensors="pt").pixel_values
generated_ids = model.generate(pixel_values, num_beams=4)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]

print(generated_text)

Training Details

Data Preparation

The training dataset was created from high-resolution scans of typewritten deed record indices. Each entry was segmented and manually transcribed to create ground truth labels.

To prevent overfitting, two augmentation strategies were applied:

  1. Column reordering: Text segments were cropped and recombined in different arrangements
  2. Noise augmentation: Applied the same noise transformations used in the original TrOCR training (see noise.py in the TrOCR repository)

Hyperparameters

ParameterValue
Batch size (per device)4
Gradient accumulation steps8
Effective batch size32
Learning rate5e-6
Weight decay0.03
Epochs10
Warmup steps200
PrecisionFP16
Generation beams4

Dataset Split

  • Training samples: 7,315
  • Evaluation samples: 813

Performance

MetricBase ModelFine-tunedImprovement
CER0.03680.0000499.9%
WER0.13710.000299.9%
Exact Match—0.9988—

Exact match was used as the primary training metric. Standard CER/WER can appear low while still producing unacceptable results for structured data extraction, so exact match provided a more reliable signal during training.

Repository

Training notebook and data preparation scripts: GitHub

Citation

If you use this model, please cite the original TrOCR paper:

@misc{li2021trocr,
  title={TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
  author={Minghao Li and Tengchao Lv and Lei Cui and Yijuan Lu and Dinei Florencio and Cha Zhang and Zhoujun Li and Furu Wei},
  year={2021},
  eprint={2109.10282},
  archivePrefix={arXiv},
  primaryClass={cs.CL}
}

Sources

1 source
Hugging FacePrimaryVersion 57116f0c7f31f288fc91285665b66363ed875c2f
huggingface.co/m-mjm/trocr-finetuned-typewritten/tree/57116f0c7f31f288fc91285665b66363ed875c2f

Verified Sep 17

Model artifacts

1 artifact

trocr-finetuned-typewritten/model.safetensors

safetensors · 1.24 GB · SHA-256 5309e3a63acb…2461 · Hugging Face

Download file

Source excerpts

2 excerpts

--- tags: - vision - ocr - trocr - image-to-text license: mit metrics: - cer - wer - exact_match base_model: microsoft/trocr-base-printed pipeline_tag: image-to-text language: - en --- # TrOCR Fine-tuned for Typewritten Text A fine-tuned version of [microsoft/trocr-base-printed](https://huggingface.co/microsoft/trocr-base-printed) optimized for typewritten historical documents, specifically U.S. County deed record indices. ## Model Description - **Base Model:** microsoft/trocr-base-printed - **License:** MIT - **Task:** Optical Character Recognition (OCR) for typewritten text This model was fine-tuned on 8,100 manually annotated images of typewritten index entries from historical deed records. It achieves near-perfect accuracy on this domain, with an exact match rate of 99.88%. ## Intended Use **Primary use case:** OCR for typewritten documents, particularly historical records with similar formatting to mid-20th century U.S. county indices. **Limitations:** This model was trained on a specific document style. Performance on handwritten text, modern fonts, or significantly different layouts has not been evaluated and may be poor. ![Segment Example](segment_example.png) ## Usage ```python from transformers import TrOCRProcessor, VisionEncoderDecoderModel from PIL import Image processor = TrOCRProcessor.from_pretrained("m-mjm/trocr-finetuned-typewritten") model = VisionEncoderDecoderModel.from_pretrained("m-mjm/trocr-finetuned-typewritten") # Load image (ensure this is a crop of a text line, not a full page) image = Image.open("your_image.ext").convert("RGB") pixel_values = processor(images=image, return_tensors="pt").pixel_values generated_ids = model.generate(pixel_values, num_beams=4) generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] print(generated_text) ``` ## Training Details ### Data Preparation The training dataset was created from high-resolution scans of typewritten deed record indices. Each entry was segmented and manually transcribed to create ground truth labels. To prevent overfitting, two augmentation strategies were applied: 1. **Column reordering:** Text segments were cropped and recombined in different arrangements 2. **Noise augmentation:** Applied the same noise transformations used in the original TrOCR training (see [noise.py](https://github.com/microsoft/unilm/blob/mast...

Source context: 0 downloads · 0 likes · Pipeline image-to-text · Repo m-mjm/trocr-finetuned-typewritten