Home / Insights / AI and Machine Learning

AI and Machine Learning

Prebuilt Document AI, Custom Models or LLMs? Choosing an Extraction Approach

There are now several credible ways to pull structured data out of documents. This guide compares prebuilt cloud models, custom-trained extractors, self-hosted OCR pipelines and LLM-based extraction, and shows how to combine them sensibly.

TopicsAI and Machine LearningGenerative AI and LLMsArchitecture and Modernization

Key takeaways

  • Prebuilt models are the fastest route for common documents such as invoices, receipts and identity documents; test them first.
  • Custom-trained extractors suit stable, high-volume document types the prebuilt models do not cover.
  • LLMs and vision language models handle varied layouts and free text well, but need schema enforcement, validation and cost controls.
  • Data residency and volume often decide between managed cloud services and self-hosted OCR and models.
  • Most production pipelines mix approaches: classify first, then route each document type to the extractor that measures best.

Five years ago, document extraction usually meant OCR plus templates or rules per supplier. Today, a team choosing a stack can pick from managed document AI services with prebuilt models, custom models trained on its own labelled samples, open-source OCR and layout models it hosts itself, and large language or vision language models that read a page and return JSON.

Each option has a different profile for accuracy, cost per page, setup effort, data handling and long-term maintenance. This article compares them from an architecture point of view and suggests a decision process. It complements our broader guide to AI document processing use cases, costs and human review.

The four main approaches

1. Prebuilt models in managed services

Cloud document AI services offer ready-made models for common documents. Microsoft’s Azure Document Intelligence, for example, lists prebuilt models for invoices, receipts, bank statements, contracts, identity documents and various tax forms, returning typed fields such as dates and currency amounts. AWS Textract and Google Document AI offer comparable capabilities. You send a document and get structured output with no training.

2. Custom-trained extractors

The same services, and open-source layout models such as LayoutLM, let you train on your own labelled documents. Azure’s documentation distinguishes custom template models for fixed layouts from custom neural models for documents with varied structure, plus classifiers that identify the document type before extraction.

3. Self-hosted OCR and layout pipelines

Open-source tools such as Tesseract OCR and OpenCV for image pre-processing, combined with layout models and your own rules, can run entirely in your infrastructure. You own the pipeline and its behaviour, and you also own its tuning and upkeep.

4. LLM and vision language model extraction

A language model is given OCR text (or the page image, for vision-capable models) plus a schema, and asked to return the fields. This handles unusual layouts and free-text clauses well and can be adapted by changing instructions rather than retraining. For background, see our guide to vision language models for business.

Side-by-side comparison

FactorPrebuilt managedCustom-trainedSelf-hosted OCR + rulesLLM / VLM extraction
Time to first resultVery fastNeeds labelled samplesSlower; pipeline to buildFast to prototype
Fit for common documentsStrongStrongDepends on effortStrong
Fit for unusual or varied layoutsLimited to supported typesGood with enough samplesWeak without heavy rulesStrong
Free-text understanding (clauses, notes)LimitedLimitedWeakStrong
PredictabilityHighHigh once trainedHighLower; needs schema checks
Confidence scoresProvided per fieldProvided per fieldPartial (OCR level)Not native; must be designed
Cost modelPer pagePer page plus trainingInfrastructure and engineeringPer token or per hosted GPU
Data residency controlRegion choice in providerRegion choice in providerFullFull if self-hosted; otherwise provider terms
Ongoing maintenanceLow; provider updates modelsRetraining as layouts changeHighestPrompt and model version management

The factors that usually decide

Document variety

If most volume comes from document types a prebuilt model supports, start there. If you have many unusual forms or need meaning from free text, such as a liability clause in a contract or a handwritten note on a claim form, LLM-based extraction is often the better fit for those parts.

Volume and cost per page

Per-page pricing is simple at low and medium volumes. At very high volumes, self-hosting OCR and smaller models can become attractive, but only once you account for GPU capacity, operations and engineering time. Model token costs also scale with page length, so long contracts behave differently from one-page receipts. Our article on reducing LLM token costs covers techniques that apply here.

Data handling and residency

Identity documents, medical referrals and financial records often carry obligations about where data is processed. Managed services usually let you choose a region; self-hosting gives complete control. PoliteTech can deploy self-hosted OCR and models in a client’s cloud account when documents need to stay in their environment.

Predictability and auditability

Finance and compliance teams want to know why a value was extracted. Classical extractors return bounding boxes and confidence scores per field. With LLMs, ask for the source text span with each value, validate against a strict schema and check that the quoted text actually appears in the OCR output.

Hybrid pipelines are the norm

In practice, the best answer is rarely a single approach. A common production pattern looks like this:

  1. Capture and pre-process: de-skew, crop, detect pages, convert formats.
  2. Classify: identify the document type with a classifier or a lightweight model.
  3. Route: send invoices and receipts to a prebuilt model; send a stable internal form to a custom extractor; send contracts or free-text-heavy documents to an LLM with a strict output schema.
  4. Validate: apply the same business rules regardless of extractor, such as arithmetic, master-data lookups and format checks.
  5. Review: route low-confidence or rule-failing values to a person in a side-by-side screen.
  6. Integrate: export to ERP, accounting or document management systems.

A useful variant is to use an LLM as a fallback or second opinion: when the primary extractor returns low confidence or validation fails, ask the LLM to extract the same fields and compare. Disagreement goes to review; agreement can raise confidence.

Failure modes to design against

  • Plausible inventions: LLMs may fill a missing field with a reasonable-looking value. Require a source span and reject values not found in the text.
  • Silent model updates: managed models and hosted LLMs change over time. Pin versions where possible and re-run your test set before switching.
  • Layout drift: template models break when a supplier changes its invoice design. Monitor exception rates per sender.
  • Prompt injection in documents: text inside a document can try to instruct an LLM. Treat document content as data, constrain outputs to a schema and never let extraction trigger actions directly.
  • Cost surprises: very long documents or retries can multiply token usage. Set per-document budgets and alerts.

A practical decision process

  1. List document types by volume and business impact.
  2. Build a labelled test set for the top types; see our guide to measuring document processing accuracy.
  3. Run the same set through a prebuilt model, an LLM-based extractor and, if relevant, a custom model.
  4. Compare per-field correctness, silent error rate, cost per document and latency.
  5. Check data handling requirements against each option’s deployment model.
  6. Choose per document type, and keep the pipeline modular so an extractor can be swapped later.

Our intelligent document processing work combines OCR, layout models and language models with validation, so the choice is driven by measured results on your files rather than by a preferred tool.

Frequently asked questions

Is an LLM always more accurate than a prebuilt invoice model?

No. On standard invoices, prebuilt models are often accurate, cheaper and more predictable. LLMs tend to add most value on unusual layouts and free text. Measure both on your own documents.

Can we avoid sending documents to a third-party cloud?

Yes. Open-source OCR, layout models and self-hosted language models can run in your own cloud account or data centre, at the cost of more engineering and operations.

How do we get confidence scores from an LLM?

LLMs do not provide reliable per-field confidence by default. Combine schema validation, source-span checks, business rules and, where useful, agreement with a second extractor to decide what needs review.

How often will we need to retrain a custom model?

When layouts or document types change enough that exception rates rise. Monitoring per-sender exceptions tells you when retraining is worth doing.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Microsoft Learn: What is Azure AI Document Intelligence? — Prebuilt model categories, typed fields, custom template versus neural models, classifiers and the layout model.

Not sure which extraction approach fits your documents?

We can run a comparison on a representative sample and show per-field results, cost per document and data handling options.