
With a five-stage pipeline: intake → OCR and layout → schema-guided LLM extraction → validation with human review on uncertain cases → automatic writing into your ERP via API. Not by uploading PDFs into a chatbot.
You integrate them by building an Intelligent Document Processing pipeline in five stages: document intake and classification; OCR with layout analysis; field extraction with an LLM guided by a schema, returning structured data rather than free text; validation with confidence scores, arithmetic checks and human review on uncertain cases only; automatic writing of the data into the management system or ERP via API. It is the fifth stage that produces the saving: data extracted but not written into your systems has merely moved the manual work, not removed it.
The counter-intuitive part is that the language model is the least critical piece of the whole. Projects do not fail because the LLM reads badly: they fail because nobody defined what happens when confidence is low, because the extracted data ends up in a file instead of the management system, or because the question of document confidentiality was raised once the project was finished. Codebaker, a software house based in Bologna and founded in 2019, designs these pipelines starting from the constraints — volumes, confidentiality, systems to feed — and builds the proprietary product Data Alchemy, dedicated to exactly this: Intelligent Document Processing with LLMs.


This is where an experiment and a production system part ways. Asking a model «what is the total on this invoice?» produces a natural-language answer that somebody then has to interpret and that changes shape every time. Asking the model instead to return a structured object with fields defined in advance — document number, date, supplier VAT number, line items with quantity and price, net amount, VAT, total — produces data another piece of software can consume without ambiguity. The schema also acts as a safety net: if a mandatory field is missing or has the wrong type, the anomaly surfaces immediately, before it reaches the management system. It is the same discipline we apply when designing APIs, applied to the output of a language model: you agree the data contract first, and the model honours it.


The documents a company would most like to process automatically are often the most sensitive: contracts, invoices carrying customer and supplier data, certificates, CVs, documents covered by trade secrecy. The question «where do these files end up» must therefore be asked at the beginning, because it shapes the architecture and cannot be fixed afterwards. There are three routes: models running on EU cloud infrastructure under contracts that exclude the use of your data for training; models running locally on company hardware, so documents never leave the perimeter; or a mixed architecture that sends outside only what is not sensitive. We design GDPR by design: minimisation of what is sent, deletion of temporary files, logs of who saw what, and a local execution option when sensitivity demands it.
Each stage has a precise job and a control point: that is what makes the system reliable enough to let it write into your management system.

Documents arrive from a dedicated mailbox, a scanner, an upload area or an existing flow, and are classified by type: invoice, delivery note, order, certificate. Nobody has to change how they receive them.

The document becomes text with the coordinates of every element, so tables, columns and rows survive as structure rather than scattered words. This stage determines the quality of everything downstream.

The model is asked for structured output with fields defined in advance, not free text. That way «Net total» and «Total net amount» land in the same field, with no need for a template per supplier.

Per-field confidence scores, arithmetic checks (line items sum to the total, VAT adds up) and reconciliation against master data. Only documents below threshold enter a review queue: the rest pass through.

Validated data enters the management system, the ERP or the document system through APIs, with the original document archived and linked to the record. This is the stage that turns extraction into hours saved.

Every processed document leaves a trace: what was extracted, with what confidence, who corrected what. That is what makes it possible to track accuracy over time and to answer an audit or a dispute.
Stage 5 rests on the same skills as integrating your management system with other software via APIs: which is why an AI document project succeeds or fails more on the integration than on the model.
They are often conflated, but they solve different problems. Picking the wrong one is the fastest way to spend money well on a problem you did not have.
| Technology | What it does | When it is the right choice | Where it breaks |
|---|---|---|---|
| OCR | Converts images and scans into text | Always, as the base stage underneath everything else | On its own it grasps no meaning: words, not fields |
| Template extraction | Maps fixed page positions to fields | Few documents, always identical, layout stable over time | As soon as a supplier changes layout: one template each |
| LLM with structured output | Reads the document and returns the fields the schema asks for | Many suppliers, variable layouts, synonyms and several languages | Without validation and confidence scores, errors pass silently |
| RAG | Answers questions by searching your documents | Contracts, specifications, manuals, regulations: consultation | Not designed to extract fields to feed a management system |
| Generic chatbot | Converses about a manually uploaded document | Occasional individual use, exploration | No automation, no traceability, no writing into systems |
In a production pipeline OCR and LLMs work together, templates are reserved for the few genuinely stable documents, and RAG is added when the need is consultation rather than extraction. The full picture on using AI in business is on the artificial intelligence for companies page and in our AI consulting.
The best candidates share three traits: high volume, a recurring but not identical structure, and a value that somebody currently retypes into a system by hand.
| Document | Fields typically extracted | Where the data lands | Difficulty |
|---|---|---|---|
| Supplier invoice | Supplier, VAT number, number, date, line items, net, VAT, total, due date | Accounts payable | Medium: many suppliers, many layouts |
| Inbound delivery notes | Sender, number, date, items, quantities, order reference | Warehouse goods-in | Medium |
| Customer orders by email or PDF | Customer, item codes, quantities, prices, requested date | Orders in the management system | Medium: requires matching against the catalogue |
| Quality certificates | Batch, measured parameters, outcome, issuing body, validity | Quality system and batch traceability | Low if the format recurs |
| Expense receipts | Date, merchant, amount, VAT, expense category | Administration and reimbursements | High on image quality, low on the fields |
| Contracts and specifications | Parties, term, deadlines, relevant clauses | Deadline tracking and consultation (RAG is needed here too) | High: long, non-tabular text |
| CVs | Personal data, experience, skills, qualifications | Recruitment system | Technically low, high on the GDPR side |
The question we get most often is not «does it work?» but «what exactly comes out?». What comes out is typed JSON, with a confidence level for every field, not free text: that is the difference between an experiment with a chatbot and a pipeline you can connect to an ERP. The LLM is not left free to answer as it pleases: the schema of the expected fields is imposed on it and the output is validated against that schema before it is written anywhere.
{
"documentType": "purchase_invoice",
"supplier": {
"name": { "value": "Rossi Componenti Srl", "confidence": 0.99 },
"vatNumber": { "value": "IT01234567890", "confidence": 0.99,
"check": "checksum_ok" }
},
"documentNumber": { "value": "2026/A/1184", "confidence": 0.97 },
"documentDate": { "value": "2026-09-03", "confidence": 0.98 },
"lines": [
{ "description": "O-ring 4x2 NBR", "quantity": 500,
"unitPrice": 0.34, "amount": 170.00, "confidence": 0.94 },
{ "description": "Shipping", "quantity": 1,
"unitPrice": 18.00, "amount": 18.00, "confidence": 0.88 }
],
"netTotal": { "value": 188.00, "confidence": 0.96 },
"vatAmount": { "value": 41.36, "confidence": 0.96 },
"grossTotal": { "value": 229.36, "confidence": 0.96 },
"checks": {
"lineSumMatchesNetTotal": true, // 170.00 + 18.00 = 188.00
"vatConsistentWithRate": true, // 188.00 x 22% = 41.36
"supplierFoundInMasterData": true
},
"outcome": "auto" // auto | review | reject
}The checks block is the part no model provides on its own and the one that makes the difference in production: these are deterministic verifications we write, not probabilistic ones. The sum of the lines must match the net total, the VAT must be consistent with the rate, the VAT number must pass its checksum, the supplier must exist in the master data. A document can have very high confidence on every field and still be wrong: arithmetic checks catch that, confidence alone does not.
The outcome field is not decided by a person: it is the result of rules agreed beforehand, and this is the table we propose as a starting point. Thresholds are then tuned on the real case and on the cost of an error, which is different for a €200 invoice and for a contract.
| Situation | What happens | Who steps in |
|---|---|---|
| High confidence on all mandatory fields and arithmetic checks passed | The document is written into the ERP with no human step | Nobody |
| Low confidence on one or more fields | Goes to the review queue with the field highlighted and the image crop it was read from | An operator confirms or corrects, usually in seconds |
| High confidence but failed arithmetic check | Mandatory review: the most treacherous case, because the value «looks» right | Operator |
| Supplier or item missing from the master data | Held: the document does not enter until the master data is aligned | Administration |
| Unreadable or unexpected document type | Rejected with an explicit reason, never «silently» | Whoever uploaded it |
The principle we apply is that automation must know when it does not know. A system that says «I am not sure about this field» and asks for confirmation is more useful than one that is confidently wrong: the first saves time, the second pollutes the ERP and forces people to check everything by hand, wiping out the benefit.
«99% accuracy» without saying of what means nothing, and it is the promise we hear most often in demos. Before signing any project, three different measures have to be defined, and they can diverge enormously.
The percentage of fields extracted correctly over the total. It is the most generous measure and the one that ends up in brochures: a document with twenty fields and one error scores 95% field-level accuracy, but it is a wrong document.
The percentage of documents in which all mandatory fields are correct. This is the measure that really counts, because a single wrong field still requires a person to handle the whole document.
The percentage of documents that cross the whole pipeline untouched. It is the only number that translates directly into hours saved, and it is always lower than the other two, because it also depends on the confidence thresholds chosen. Raising the thresholds reduces errors and also reduces automation: the balance point is a business decision, not a technical one.
What an error that gets through costs. On a purchase invoice it is a credit note and a phone call; on a delivery note it can be a wrong delivery; on a contract it can be far worse. It is the number that determines where the thresholds go, and the company has to decide it before looking at any demo.
About a hundred real documents, taken exactly as they actually arrive — skewed scans, faxes, PDFs photographed with a phone and the formats of that one supplier who sends everything their own way. Against these, a ground truth set established by someone inside the company is measured blind, and the four numbers above are produced. If the result does not justify the project, we say so: it is the most useful outcome a pilot can have, and it costs infinitely less than finding out after go-live. The same logic as the incremental method: one pilot process, measured before and after with numbers agreed up front.
A warning we always give: a sample made only of «clean» documents produces brilliant, unusable results. The quality of a document project is decided on the ugly cases, not the pretty ones.
Four routes lead to the same goal, with very different consequences two or three years out. None is wrong in the absolute: what changes is which problem you are solving.
| Criterion | Subscription IDP platform | Cloud document AI service | Outsourced data entry | Bespoke pipeline (Codebaker) |
|---|---|---|---|---|
| Getting started | Fast on standard documents | Fast, but someone must integrate it | Immediate | Measured pilot before development |
| Cost over time | Fee per document or per user | Metered, grows with volume | Linear on volume: it never goes down | Upfront investment, then maintenance only |
| Non-standard documents | Only if in the catalogue | Needs training or post-processing | Yes, but at full cost | Yes: you define the schema |
| Business validation rules | Limited to those provided | To be built downstream | Depends on the instructions given | Native: master data, VAT rates, balances, credit limits |
| Writing into the ERP | Connectors, where they exist | To be developed | Often manual | The starting point, not an add-on |
| Where the documents end up | Depends on the vendor | On the provider's cloud | Seen by people outside the company | Your choice: European cloud or a local model |
| Confidentiality and GDPR | To be checked case by case | Provider's contract | External data processor | By design: the data need never leave the company |
| Ownership | None: stop paying, lose everything | The integration code is yours | None | Code, schema and prompts owned by the customer |
The rule of thumb: if your documents are standard, the volumes modest and your ERP already has a connector, a subscription platform is the rational choice and we would tell you so. If the documents follow your own rules, if the management system is dated, or if the data cannot leave the company, the subscription ends up paying for flexibility that never arrives. Cost brackets for a bespoke project are published on how much custom software costs.
Codebaker is a software house based in Bologna, founded in 2019, that builds custom software, apps, APIs and AI integrations in-house. The source code stays the customer's property.
What it is based on
An AI document project is 20% a modelling problem and 80% a problem of integration, data and processes: the three things we have always done. We are a software house based in Bologna, founded in 2019, with projects in production for years on precisely the hard part — getting correct data into systems that already exist.
Proprietary Intelligent Document Processing software: it extracts structured data from business documents by combining OCR and LLMs. When your case falls within its scope, you start from here rather than from scratch.
The hardest stage of a document pipeline is the last one. Here we feed an AS400 system in real time: 300,000+ orders a year, 5,000+ customers a day.
Process automation over the data of more than 2,000 employees, integrated with SAP, HR, Active Directory and Office 365: -95% of manual IT onboarding work.
Our authentication system with distributed encryption and native GDPR compliance, launched in 2024: the same care for data that we bring to document projects.
Useful reading before deciding: which hardware you need to run LLMs locally, ChatGPT in the workplace and data security and data security in AI projects.
You integrate them by building an Intelligent Document Processing pipeline in five stages, not by uploading PDFs into a chatbot. Stage one, intake: documents arrive from a mailbox, a scanner or an upload area and are classified by type. Stage two, OCR and layout analysis: the document becomes text with the coordinates of every element, so tables and columns remain readable. Stage three, schema-guided extraction with an LLM: the model is asked to return structured output with fields defined in advance (document number, date, VAT number, line items, net amount), not free text. Stage four, validation: every field gets a confidence score, arithmetic checks and reconciliation against master data are applied, and only uncertain documents go into a human review queue. Stage five, writing: the validated data enters the management system or ERP via API, with the original document archived and linked. It is the fifth stage that produces the saving: data extracted but not written into your systems has merely moved the manual work elsewhere.
OCR converts an image into text but does not know what it means: on its own it does not give you the invoice total, it gives you every word on the page. Template-based systems map fixed positions to fields: they work very well on documents that are always identical and break as soon as a supplier changes layout, which in companies with hundreds of suppliers is the norm. LLMs read the document the way a person would: they understand that «Net total» and «Total net amount» are the same thing and find the value even when it has moved, without needing a template per supplier. RAG is something else again: it is not for extracting fields from a document but for answering questions over a document collection, and it is the right choice for contracts, specifications and manuals. In practice a solid pipeline uses OCR and LLMs together, and reserves templates for the few genuinely stable documents.
Accuracy must be measured, not promised: the correct number depends on the document type, the quality of the scans and how many different suppliers there are, and anyone quoting a percentage before seeing your documents is guessing. The serious method is to build a reference set of documents already verified by hand, measure the extraction against it field by field, and repeat the measurement after every change. In production, accuracy is governed by four mechanisms: per-field confidence scores, arithmetic checks (line items must sum to the total, VAT must add up), reconciliation against existing master data and a human review queue for documents below threshold only. The goal is not an infallible model, it is that no error reaches your systems without being intercepted.
It depends on how the solution is designed, and it is a decision to take at the start rather than at the end. There are three options: models running on EU cloud infrastructure under contracts that exclude the use of your data for training; models running locally, on company hardware, so documents never leave the corporate perimeter; or a mixed architecture that sends only non-sensitive documents to the external model. We design solutions GDPR by design: minimisation of what is sent, deletion of temporary documents, traceability of who saw what, and the option of running everything locally when sensitivity demands it. If you process special category data or documents covered by trade secrecy, local execution is the route to evaluate first.
The best candidates share three traits: high volume, a recurring but not identical structure, and a value that somebody currently retypes into a system by hand. In practice: supplier invoices from many different vendors, inbound delivery notes, customer orders received by email or PDF, order confirmations, quality certificates and datasheets, customs documents, expense receipts and CVs. In all of these the work is transcription rather than judgement, and human error from fatigue is more likely than model error. What does not make sense is starting from rare documents, or from those where the decision matters more than the data: there, AI can help you read, not decide.
It depends on confidentiality, volume and cost. Cloud is preferable when the documents are not particularly sensitive and volumes vary: there is no hardware to buy and you pay per use. Local execution is preferable when documents cannot leave the company for confidentiality or contractual reasons, when volumes are high and steady (at which point the hardware amortises), or when you need the guarantee that no data is used to train third-party models. We have written a dedicated guide to the hardware needed to run LLMs locally, with realistic configurations for a company.
A pilot project on a single document type, with simple integration into the management system, typically falls in the €5,000-15,000 band; a solution covering several document types with validation, a review interface and full integration falls in the €15,000-50,000 band; document platforms spanning several flows and sites go beyond €50,000. On top of this sits the cost of running the models, pay-per-use in the cloud or as hardware if you choose local execution. The calculation that really matters, though, is a different one: how many hours a week your company currently spends retyping data from documents, and what eliminating most of that is worth.
From a single high-volume document type, having first measured what it costs you today. The path we recommend is: pick the most frequent document (often the supplier invoice or the inbound delivery note), gather about a hundred real examples including the ugly ones, define the fields to extract and the validation rules, measure accuracy against that set, and only then connect automatic writing into the management system. A pilot like this is bounded, measurable and requires no change in how the company works: operators simply stop typing and start validating exceptions.
Data Alchemy is Codebaker's proprietary product for Intelligent Document Processing: it extracts structured data from business documents by combining OCR and LLMs and returns output ready to be written into management systems. It grew out of our experience on client projects and is used as a starting point when the required solution falls within its scope, cutting time and cost compared with building from scratch; when the document flow is unusual, we develop a bespoke pipeline instead. In both cases our principles hold: data handled GDPR by design and integration with the systems the company already uses.
Structured data, not free text: typed JSON matching a schema agreed with the company, with a confidence level for every field and a block of deterministic checks. On a supplier invoice, for example, out come the supplier with its VAT number, the document number and date, the lines with quantity, unit price and amount, the net total, the VAT and the gross total, each with its own confidence; alongside them, checks that do not depend on the model: the sum of the lines must match the net total, the VAT must be consistent with the rate, the VAT number must pass its checksum, the supplier must exist in the master data. That is the difference between an experiment with a chatbot and a pipeline you can connect to an ERP: a document can have very high confidence on every field and still be wrong, and it is the arithmetic checks that catch it.
With four distinct numbers, because «99% accuracy» without saying of what means nothing. Field-level accuracy is the percentage of correct fields over the total, and it is the most generous measure: a document with twenty fields and a single error scores 95%, yet it is still a wrong document. Document-level accuracy is the percentage of documents where all mandatory fields are correct, and that is the one that matters, because a single error still requires a person to handle the whole document. Straight-through processing rate is the percentage of documents crossing the pipeline untouched: it is the only number that turns into hours saved, and it is always lower than the other two because it depends on the confidence thresholds chosen. The fourth is the cost of the residual error, which decides where to put those thresholds. All four have to be measured on a sample of real documents taken as they actually arrive, skewed scans and phone photos included: a sample of clean documents only produces brilliant, unusable results.
The document is not written: it enters a review queue with the uncertain field highlighted and the image crop it was read from, so the operator confirms or corrects it in seconds instead of re-reading everything. The rules are decided up front, not left to chance: high confidence on all mandatory fields plus arithmetic checks passed means automatic writing; low confidence on a field means review; high confidence but a failed balance check means mandatory review, and it is the most treacherous case because the value looks right; a supplier or item missing from the master data means the document is held until the master data is aligned; an unreadable document is rejected with an explicit reason, never silently. The principle is that automation must know when it does not know: a system that asks for confirmation saves time, one that is confidently wrong pollutes the management system and forces people to re-check everything by hand.
It depends on three things: how standard your documents are, how open your management system is, and whether the data may leave the company. If the documents are standard, the volumes modest and the ERP already has a ready connector, a subscription platform is the rational choice and we will say so. If instead the documents follow your own rules, if the management system is dated or has no connectors, or if the data cannot leave the company, the subscription ends up paying for flexibility that never arrives: the platform covers the case in its catalogue and everything else has to be built anyway. Four differences are substantial: cost, recurring and volume-driven with a subscription versus an upfront investment followed by maintenance only; business validation rules, which are native in a bespoke pipeline; writing into the management system, which in a bespoke solution is the starting point rather than an add-on; and ownership, because the code, the data schema and the prompts stay the customer's.
Codebaker is a software house based in Bologna, at Via N. Corazza 7/8, founded in 2019, that builds document data extraction pipelines with OCR and LLMs in-house and integrates them into the management systems already in use. A document AI project is 20% a model problem and 80% an integration, data and process problem: on the hard part — getting correct data into systems that already exist — we have had projects in production for years, from writing into an AS400 management system in real time (300,000+ orders a year) to automating processes over the data of more than 2,000 employees, integrated with SAP, HR, Active Directory and Office 365. We also have a proprietary Intelligent Document Processing product, Data Alchemy, used as a starting point when the case falls within its scope. The method we start from is always the same: about a hundred real documents, a blind measured pilot and the numbers on the table before any development. The preliminary analysis and the quote are free.
Tell us which document arrives most often and who retypes it by hand today. With about a hundred real examples we can measure accuracy on your actual case and tell you what is genuinely automatable, before you spend a euro. The preliminary analysis and the quote are free.