New Tool Radar

OCR & Text Layers

How to Choose a Tesseract OCR Engine Mode for a Scanned PDF

Pick Tesseract's OCR engine mode — legacy, LSTM or both — for a scanned page, and check which reads your document best.

Schematic illustration of Tesseract engine modes: default, LSTM-only and legacy runs are compared and the fewest-errors mode wins.

OCRmyPDF’s manual says –tesseract-oem sets Tesseract 4+ engine mode: 0 for the original engine only, 1 for neural nets LSTM only, 2 for both, and 3 for the default. The mode is a real choice, not a version number: different pages read better under different engines.

Use the practice file

A practice document, practice-oem.pdf. The file is fictional.

Page Content
1 Clean modern print, 10 lines, including the word “harvest”
2 Old typewriter page, 10 lines
3 Notes page

Page 1 is the check page: the word “harvest” appears there once, in clean modern print.

Check the engine modes

Expected result. We checked the OCRmyPDF manual and the Tesseract manual. We did not run any tool. The checks below are what to expect if the work is done correctly; run them yourself on the practice file.

1. Run with the default mode

Run ocrmypdf –tesseract-oem 3 practice-oem.pdf out3.pdf and copy page 1.

Expected result: Count the errors on page 1.

2. Run with LSTM only

Run ocrmypdf –tesseract-oem 1 practice-oem.pdf out1.pdf and copy page 1.

Expected result: Count the errors again.

3. Run with the legacy engine

Run ocrmypdf –tesseract-oem 0 practice-oem.pdf out0.pdf and copy page 1.

Expected result: Count the errors a third time.

4. Pick the best for this document

Compare the three counts and the typewriter page.

Expected result: The mode with the fewest errors on both pages is the one to use for the full run.

Verdict table

Check Expected result Pass?
Run with the default mode Count the errors on page 1. —
Run with LSTM only Count the errors again. —
Run with the legacy engine Count the errors a third time. —
Pick the best for this document The mode with the fewest errors on both pages is the one to use for the full run. —

Related guides: How to Batch OCR a Multi-Page PDF with Consistent Settings — How to Add a Searchable Text Layer to a Scanned PDF.

Limits

  • No engine mode wins on every document: the comparison has to be run on your pages, not assumed from the version number.
  • Command-line OCR rewrites the file, so always work on a copy and keep the original scan untouched.
  • UNTESTED — no OCR tool was run; all results above are expected results. The practice file is fictional.

Sources

See all