OCR, LLMs or templates: which should read your documents?

Updated

In short

They are not alternatives. OCR turns a picture of text into text. Templates and language models turn text into named values. Use templates for the same kinds of document in volume, because they give the same answer every time at almost no cost; use a language model for many different layouts, and check its output, because it can return plausible values that are not on the page.

OCR, language models and templates are often compared as if they were rivals. They are not: they do different jobs, and a working system usually uses two of them. The confusion comes from treating "reading a document" as one step when it is two.

  1. Get the text. Turn the file into characters, with their places on the page.
  2. Get the meaning. Decide which of those characters are the invoice number.

OCR is a tool for step 1. Templates are a tool for step 2. A language model can attempt both at once.

What each one is

OCR turns a picture of text into text. It knows nothing about invoices or dates; it reports the characters it sees. You need it only when the page is a picture: a scan or a photo. A PDF exported from a program already contains its text, and reading it directly is faster and exact.

A template is a set of rules for one kind of document: the value after this label, the number in that box. It reads the same thing from the same place every time. It needs text to work on, from the file or from OCR.

A language model reads a page, as text or as a picture, and answers questions about it in one step. A vision model does the OCR and the understanding together.

IDP, intelligent document processing, is not a fourth technique. It is the industry's name for products that combine these, usually with classification and a screen where people check doubtful results.

How they compare

QuestionOCR aloneOCR or text + templateLanguage model
Gives youTextNamed valuesNamed values
Same file, same answerYesYesNot guaranteed
A layout it has never seenReads it, as textFailsUsually copes
Kind of mistakeMisread charactersReturns nothing, or the wrong field if the layout movedA plausible value that is not on the page
Cost per pageLowLowHigher, paid every time
SpeedAbout a second for a scanMilliseconds once there is textSeconds
Can show where a value came fromIts positionThe rule and the positionNot reliably
SetupNonePer kind of documentA prompt

The mistakes are the real difference

Every method is wrong sometimes. What differs is how.

OCR misreads a character: a 5 for an S, a missing decimal point. The mistakes are small, local, and tied to image quality; you can measure them, as in how to measure OCR accuracy, and reduce them, as in how to improve it.

A template fails structurally. If a label is missing it returns nothing, which is easy to catch. If the layout shifted and the rule was tied to a fixed position, it returns the wrong text, which is not. Template-based extraction shows both cases and how anchoring to labels avoids the second.

A language model fails plausibly. Asked for a tax number that is not on the page, it may return something shaped like a tax number. Nothing in the output marks it as invented. This is the mistake that costs the most, because it passes a casual check.

Which to use

The same few kinds of document, in volume. Templates, on text from the file or from OCR. Bank statements from one bank, invoices from regular suppliers, your own forms, government extracts. You get the same answer every time at almost no cost per page.

Many kinds, a few of each. A language model, with checks on every value. Building a template for a layout you will see twice is not worth it.

Scans of any of the above. OCR first, then one of the two.

Money, identity, anything audited. A method that is repeatable and can show its source. If you use a model, keep a person on the values that matter.

You only need the text, for search or for a model to read. OCR for scans, direct reading for everything else. No template, no extraction model.

Using them together

The strongest setups use each where it is good:

  • A model to build, rules to run. A language model looks at sample documents and writes the extraction rules; the rules are tested against the samples and then run on everything after, with no model in the loop. You get a model's ease of setup and a template's repeatability.
  • A template first, a model for the leftovers. Known kinds go through templates. Whatever does not match any goes to a model, or to a person.
  • A model to extract, rules to check. Whatever produced the values, arithmetic and format checks decide whether to trust them.

Where 100sands sits

100sands is the first of those three combinations, for files that already contain text. It reads PDFs and HTML files directly and does not do OCR, so it does not read scans or photos. You set up a document type by uploading one to five samples; AI suggests the fields and each sample's values, you check and correct them, and AI sets up the extraction. It goes live only when it returns every value you checked on every sample. From then on documents are read by that fixed extraction, so the same file always gives the same fields, and a value that is not in the document comes back empty, never guessed. AI is used at setup, not per document.

That makes it a fit for the first case above, the same kinds of document in volume, and not for the second: it is not built for one-off layouts. The PDF data extraction API page shows the setup and the call.

Questions

Is an LLM better than OCR?

They do different jobs. OCR produces the text of a scanned page. A language model interprets a page and returns values. A vision model can do both at once, at a higher cost per page and without a guarantee of the same answer each time.

What is the difference between OCR and IDP?

OCR is one technique: reading text from images. IDP, intelligent document processing, is a product category that combines OCR with classification, data extraction and human review.

When should I use templates instead of AI?

When you process the same kinds of document in volume and need repeatable results: invoices from regular suppliers, statements from one bank, your own forms. Templates are fast, cheap per page and can show where each value came from.

Do LLMs make mistakes when extracting data from documents?

Yes, and the typical one is a plausible value that is not in the document. Ask for null when a value is missing, check formats and arithmetic, and confirm that each returned value appears in the document's text.

Try it on your own documents

A free plan every month, no credit card. See the PDF data extraction API.

Start free