How to extract document data with AI and check the result

Extracting document data with AI means turning text and visual elements into fields a system can use. The process is complete when every value can be checked against the original and passes the destination’s rules. This guide organises extraction from operational documents, from the initial sample through to review and recording.

By Lyntev. Updated on .
About 5 minutes to read.

The answer starts with the sourceApproved information, defined access and a verifiable answer.

Translation published on . Original Portuguese guide; source revision .

By the end, you can:

  • Define fields and normalisation
  • Check extraction by field and document type
  • Create a review queue with the source visible

Start with one family of documents

Choose a family with a clear purpose, such as service reports or purchase requests. Gather examples with different formats, languages, scans and quality. Separate digital files with selectable text from photographs needing character recognition. Do not evaluate the system only on the cleanest documents.

Record what needs to happen afterwards: populate a draft, look up an existing record or prepare a check. Extraction alone must not authorise a payment or replace commercial validation. If the document contains restricted data, confirm the processing conditions and limit the sample to what the task needs.

Define the meaning of every field

For each field, write its name, type, unit, whether it is required and what happens when it is missing. A document number is often text: it may contain leading zeros, slashes and prefixes. A date without country context can be ambiguous. An amount without a currency must not silently inherit the company’s most common currency.

Separate the value read from the normalised value. For example, keep “1.250,00 EUR” as textual evidence and 1250.00 with currency EUR as the interpretation. The transformation needs an explicit rule. Returning an object with the correct format makes integration easier, but does not prove that the values match the document.

Define the meaning of every field
FieldProposed representationWhen to review
ReferenceText exactly as it appearsTruncated or contradictory reference
DateOriginal value and normalised dateAmbiguous day and month
QuantityNumber and unitMissing or incompatible unit
TotalAmount, currency and source document regionIllegible value or failed reconciliation

Keep the link to where the value was read

A useful review interface shows the field beside the corresponding page. Save the file reference, page and source passage or region supplied by the service. Document AI documentation describes text and structural information in the returned object; confirm which fields are available in the chosen processor.

Tables require extra care: a detail row belongs to an entity, and repeated headings are not new items. Check multi-page documents and notes beside values. If the relationship between quantity and price is lost during reading, the text can look complete while the structure is wrong.

Check a fictitious report before recording it

Fictitious report INT-042 contains two hours of work at 30 € per hour and one part at 20 €. The stated subtotal is 80 €; the document provides no additional tax information. Extraction prepares these elements for review and does not infer taxes, discounts or terms that are not present.

The control calculation is 2 × 30 + 1 × 20 = 80. If the system reads 8 instead of 80, reconciliation flags the difference. If it reads all values consistently incorrectly, the calculation can pass: arithmetic validation therefore complements checking the original. Critical fields need their own criteria.

Fictitious example of a field with source and statusJSON
{
  "documento": "INT-042",
  "subtotal": {
    "texto_original": "80,00 EUR",
    "valor": 80.00,
    "moeda": "EUR",
    "pagina": 1,
    "estado": "aguarda_revisao"
  },
  "informacao_fiscal": null
}

Evaluate each field before defining automatic approval

Create a human reference for test documents and compare each field against it. Google’s documentation distinguishes precision and recall and shows how the confidence threshold changes what is accepted. A stricter threshold can send more correct fields for review; the choice should consider the actual errors and the workload created.

In a teaching example, 100 documents have a required reference. The system returns 92 references, of which 88 are correct: precision is 88 ÷ 92, approximately 95.7%; recall is 88 ÷ 100 = 88%. Documents with missing values remain pending. An average across all fields can hide a worse rate in precisely the field that determines the record.

Handle missing values, duplicates and document changes

Distinguish three statuses: confirmed value, value absent from the original and inconclusive reading. An empty field must not be filled from another document just because it looks similar. During review, allow correction, keeping it absent or requesting a new copy, recording who decided and which version was used.

A resent file must not create two entries. Define a processing reference and check the document’s identity and version; the filename alone is weak because it can change or be repeated. A corrected version may require replacing a draft or starting a review, rather than being discarded as a duplicate.

  • Do not lose leading zeros in identifiers.
  • Do not confuse a decimal comma with a thousands separator.
  • Do not accept one readable page as evidence that the whole file was read.
  • Do not confuse a confidence score with human confirmation or a guaranteed probability.

Deliver a map of extraction and checking

The worksheet should let a technical person implement and an operational user review the same result. After launch, keep authorised examples of errors and review the sample when new formats appear. Approved corrections can improve evaluation; they should only enter training or reuse when that use is defined.

Worksheet for your project

Document family and purpose:
Formats, languages and observed quality:
Fields, types, units and required status:
Normalisation rules:
Source saved: file, version, page and region:
Arithmetic rules and permitted cross-checks:
Handling of absent / inconclusive / confirmed:
Critical fields and review criteria:
Test sample and human reference:
Precision and recall per field, with counts:
Document identity and duplicate policy:
Destination after approval, owner and retention:

Sources and criteria

Content prepared with AI assistance and research using technical sources, with checks of the relevant examples and calculations. The references support the guide’s decisions; examples identified as fictitious let you try out the method.

Wellinton Oliveira

Written by

CEO of Lyntev

Technology with context, original analysis and sources you can consult.