Document AI: Why Does It Fail in Production?

Avatar
Author

Because document AI extraction is the easy part. What separates a demonstration from a production system is disambiguation, meaning knowing that three different spellings are the same entity and that two identical spellings are not. Also knowing when the model should refuse to answer rather than risk it.

Most projects also begin without the one artefact that makes everything else measurable, namely a set of cases with the correct answer known, defined before anyone chooses a model.

We can speak with specific numbers. We rebuilt DIGITARQ for the Directorate-General for Books, Archives and Libraries. One search now covers 20 archives, across more than 8 million descriptive records and more than 63 million digitised images, corresponding to over 100 kilometres of physical documentation. We trained named entity recognition and disambiguation models for Portuguese archival metadata, on the Portuguese state advanced computing and supercomputing network. The full project write-up is in our case studies.

10.8M
Actors in the graph: people and collective bodies
16M
Interconnected events
189,000
Places
8M
Documents, in a graph modelled on CIDOC-CRM
Document AI extraction is the easy part. Disambiguation is the part that gives value to everything else.

Document AI extraction, classification and entity recognition: what is the difference?

They are distinct tasks with distinct difficulties, and they are frequently sold as though they were one. Confusing them is why a budget comes up short.

Extraction
Pulling out values
Dates, amounts, numbers, fields. Hard when layouts vary and scanning quality is irregular. Solvable and measurable.
Classification
Assigning a category
To the document or its content. Hard when boundaries between categories are fuzzy, and when the people in the company do not use them consistently.
NER
Identifying entities
People, organisations, places, marked in the text. Hard with irregular names, abbreviations and forms the model has never seen.
NED
Resolving to a single entity
Each mention linked to a canonical node. This is the genuinely hard part, and the one that gives value to the rest.
Recognising a name is half a task. The same character string can refer to many different people, and the same person can appear written a dozen ways. Without disambiguation you have a list of places where a sequence of characters appears. With disambiguation you can answer a question about a person.

Why is disambiguation harder than document AI extraction?

Because it requires a decision the model cannot take on its own: what counts as the same entity.

In DIGITARQ, the previous system treated "Torre do Tombo", "ANTT" and "Arquivo Nacional" as three different text strings. A person baptised in a parish record held in one archive and named in a will held in another were two unconnected records. The value of an archive lives in the connections, and the data was stored as isolated records and searched as plain text.

The enterprise version of the same problem looks like this. A single company appears as a supplier under four legal names, three historical tax numbers and two abbreviations. One employee shows up with and without a middle name, with and without accents. Contract references arrive in different numbering formats depending on who typed them. None of these cases is solved by a better model. They are solved instead by a business decision about what constitutes identity, written down before the project starts.

The chain that produces value
NER
Identify and mark the entities in the text, with a model evaluated on the right domain
NED
Resolve each mention to a canonical entity, against a written definition of identity
Graph
Link entities, events, places and documents in a standard data model
The question nobody asks in the first meeting: what should happen when the system lacks sufficient confidence? A useful system knows how to refuse. One that always returns an answer transfers the verification work to whoever trusts it, and that is how silent error accumulates.

What do you need before starting a document AI extraction project?

In batch, in most cases, and this is the architectural decision with the largest impact on cost. In DIGITARQ, recognition and disambiguation ran as batch processing over the entire migrated dataset. Entities were extracted and resolved once, across all the data, and they feed the platform. The models are not invoked in real time as users browse.

Batch
Predictable and auditable
The cost is paid once per document. No latency for the user, because search consults results already computed. Reprocessing is explicit and controlled when the model improves. And there is a dated, reproducible result.
Real time
Where it is justified, and what it costs
The cost is paid per query, including repeated ones, and model latency enters every interaction. Different users can get different results, and reconstructing what the system answered and why is difficult.
Real time is justified when the document arrives in the moment and the decision cannot wait, such as on receipt of a request. Even then, the pattern that works is to process on arrival and store the result, not to process on every read.

Why does document AI extraction fail on Portuguese?

Because the linguistic variation is greater than what generic models were calibrated for, and our own experience came from the extreme version of that problem. Historical Portuguese is irregular, heavily abbreviated and inconsistently spelled across centuries. Off-the-shelf document AI extraction is not enough for that material, so we adapted and evaluated the models specifically for this domain, comparing modern transformer architectures to select the best performer on archival language.

That is the extreme, but the same logic applies well before it. A generic model recognises common Portuguese names and fails on the less common, which is exactly where errors hurt. Domain vocabulary, whether legal, technical or sector-specific, is not represented either, because the model sees words rather than concepts from your business. Old documents inside a modern company also follow different conventions, since twenty years of contracts contains several writing regimes.

So the practical conclusion is not always to train your own model, which is expensive and frequently unnecessary. Instead, evaluate every candidate on your own material before choosing.

Have a corpus where generic document AI extraction fails? That is exactly the kind of problem we prefer.
Talk to our team

What should stay with you after the project?

Four things, and none requires technology. They determine whether the project is measurable.

A reference set. Real documents, with the correct answer annotated by someone who knows, including the cases that embarrassed someone in the past. Without this there is no way to compare two suppliers or two versions, and evaluation becomes impression.
A written definition of each entity type. What counts as a supplier, what counts as the same person, what counts as a contract. Written down, with one person responsible for deciding boundary cases.
A decision about refusal. What confidence level makes the system say it does not know, and where that case goes.
A decision about what you keep. Extraction produces personal data from documents that already contained it, and minimisation applies to the output as much as to the source. Keeping everything because it was available is a liability, not a record.

The first is the one most often missing and the most costly to lack. Building a reference set is annotation work by someone who knows the material, and it turns the rest of the project into a measurement rather than an argument.

When does this fall within the AI Act?

It depends on what you do with the result, not on the technology used, and the distinction is useful because it avoids unnecessary compliance scope. Extracting fields from an invoice and classifying documents for filing is not, in itself, a high-risk case. Using the result to make decisions about people can be. The Annex III categories of Regulation (EU) 2024/1689 include areas such as employment, credit assessment and access to public services, and those obligations were deferred to 2 December 2027 by Regulation (EU) 2026/1744, which entered into force on 27 July 2026.

The Article 50 transparency obligations, on marking generated content, apply to those who generate content. A system that extracts and classifies is not typically generating, but if the same product also produces summaries or text, that part is. In practice: classify the use, not the technology, and do that analysis at the start. Our summary of what changed in the AI Act in August 2026 sets out which obligations moved and which did not.

What should stay with you?

Five things, and the first is the one most often lost. The reference set and the evaluation results, which is the asset that lets you change supplier or model without starting over. The data model, including entity definitions and disambiguation rules, in a readable format. The extracted data, in a schema that does not depend on the platform that extracted it. The record of what was processed, when, and with which model version, without which you cannot know what needs reprocessing. And documentation of the decisions, including boundary cases.

A note on open standards. In DIGITARQ the graph was modelled on CIDOC-CRM, the ISO 21127 standard for cultural heritage information interoperability, with a revised edition published in 2023, precisely so the institution can sustain and develop the platform long term without depending on a single supplier. The choice of a standard data model is the decision that most determines whether the project outcome is still yours in ten years.

Frequently asked questions

Document AI extraction, NER and NED

What is the difference between NER and NED?
Named entity recognition identifies and marks the entities present in text, such as people, organisations and places. Named entity disambiguation resolves each mention to a single canonical entity, so that all references to the same person or organisation link to the same node. The second is the hard part and the one that gives value to the first.
Why do document extraction projects fail in production?
Because extraction is the easy part. They fail on disambiguation, on the system not knowing how to refuse when it lacks sufficient confidence, and on the absence of a reference set with the correct answer known, without which there is no way to measure whether the system works.

Batch architecture and language

Should document processing run in batch or in real time?
In batch, in most cases. The cost is predictable and paid once per document, there is no model latency in the user experience, reprocessing is explicit when the model improves, and there is a dated, reproducible result for audit purposes.
Do generic models work on documents in Portuguese?
They work on common material and degrade on the less common, which is where errors hurt. Domain vocabulary is not represented, and old documents inside a modern company follow different conventions. The answer is not always to train your own model, it is to evaluate on your own material before choosing. The questions worth asking a supplier at that point are in what to ask an AI agency before you sign.

Prerequisites and regulation

What do you need before contracting a document AI project?
A reference set of real documents with the correct answer annotated, a written definition of each entity type with someone responsible for boundary cases, a decision about what happens when the system does not know, and a decision about what you keep from the result.
Does AI document extraction fall within the AI Act?
It depends on what you do with the result. Extracting fields and classifying documents is not, in itself, a high-risk case. Using the result to make decisions about people can be, given that Annex III of Regulation (EU) 2024/1689 covers areas such as employment, credit and access to public services, with obligations deferred to 2 December 2027.
Caixa Mágica Software
Caixa Mágica Team
Caixa Mágica Software is a Portuguese software company with 20+ years of experience delivering custom software, AI solutions and nearshore development teams for European businesses.
AI Lab · Caixa Mágica Software
Bring us the difficult material
We trained named entity recognition and disambiguation models for Portuguese archival language and ran them across more than 8 million records, with the result in a graph holding more than 10.8 million actors. Send us a hundred representative documents, including the worst ones.