How does an AI document processing agent turn PDFs and forms into data?
The steps from scanned page to structured record
A document has to pass through a few stages before its contents are usable. The file is received, text is recognised if the document is a scan or a photo, a language model maps the text to the fields you defined, and the values are checked. Only then are they written to a database, a spreadsheet or a line-of-business system.
Digital PDFs with a text layer skip most of the recognition step, so they are cheaper and more accurate to process. Scans, faxes and phone photos need optical character recognition first. Test both kinds of file separately, because a pipeline that works well on clean exports can fail quietly on crooked scans.
- Receive: files arrive by email, upload, a shared folder or an API.
- Recognise: optical character recognition turns images into text, with page and position kept.
- Extract: the model maps text to your fields and returns each value with its source.
- Validate: rules check formats, required fields and cross-field logic.
- Store: the record and the original file are saved together, and a person reviews what fails.
Define the fields before you choose the tool
Most failed document projects start with a vague goal such as read the forms. Begin instead with a schema: a short list of fields, the type of each one, whether it is required and what a valid value looks like. A date field should have a format. An amount should have a currency. A reference number should follow a pattern your team already uses.
Collect a sample of real documents before you design the schema. Include the bad ones: smudged prints, handwriting, stamps over text, and pages where the form changed between versions. The sample shows you which fields are reliable and which need a person in the loop.
Confidence, validation and the review queue
A good extraction gives you two signals for each field: the value and a measure of how sure the system is about it. Use the signal to route work, not as a promise of accuracy. A confident model can still be wrong, and a low-confidence field may be correct. Set your thresholds after testing on your sample, and adjust them as you see real errors.
Validation catches many errors that confidence cannot. A date that falls after the signing date, a total that does not match the line items or a tax number with the wrong length should go to review no matter how sure the model sounds. Send each flagged field to a review screen that shows the original page beside the extracted value, so the reviewer can correct it in a few seconds.
- Auto-accept: fields that pass validation and fall above the threshold you set.
- Review: fields that fail a rule or fall below the threshold.
- Reject: documents that are unreadable, the wrong type or missing required pages.
Keep the source next to the result
Store the original file, the page number and the region where each value was found, next to the extracted value. When someone asks why a figure says what it says, the answer should take a few clicks, not an afternoon of searching. This is also the best defence against a silent error that spreads through a database.
Keep the original file unchanged. Do not let the pipeline overwrite scans with cleaned copies, because you may need the untouched version for an audit or a dispute. Apply retention rules to the originals, and limit access to people who need the personal data they contain.
Mistakes that make document agents unreliable
The most common mistake is measuring accuracy on easy documents and assuming the result holds for the rest. Another is treating the model's output as the record without a validation step, so a misread digit goes straight into a report. Teams also forget that forms change, and an extraction that worked last year can drift when a supplier or agency updates its template.
Build a regression test from your sample, so every change to the model, the prompt or the schema is checked against the same documents. Track the share of fields sent to review each week. A rising share is an early warning that the inputs have changed. Mixed scripts, such as Traditional Chinese characters beside English codes, also need test documents of their own.
How Hundred Seas helps
Hundred Seas builds AI agents for document-heavy work, including extraction pipelines with validation rules and review screens. We build on Claude and on OpenAI models, and we choose the model for each document type on cost, speed, quality and where the client's data has to stay, which matters when documents hold personal or financial details.
Every project begins with a scope step of about one week at a fixed price, finishing in a written plan, a clickable prototype and a firm quote. Building follows in weekly releases of working software, and a monthly run plan keeps the schemas, thresholds and test set in line with the documents you actually receive.
Questions
- How accurate is AI at reading scanned documents?
- Accuracy depends on scan quality, handwriting, layout and how clearly each field is defined. Measure it on your own sample rather than relying on a general figure. Route low-confidence and failed fields to a person, so the final record is checked even when the average accuracy is high.
- Can the agent handle handwriting and stamps?
- Some handwriting reads well and some does not, and stamps often hide the text beneath them. Treat handwritten and stamped fields as higher risk, send them to review by default, and test them separately. Where a field is critical, consider asking the sender for a typed version.
- Should I keep the original scan after extraction?
- Yes, keep it unchanged, and store it beside the extracted record. The original is your evidence if a value is disputed, and it lets you re-run extraction when the model or schema improves. Apply a written retention rule so originals are deleted when they are no longer needed.
- What is the difference between OCR and a document AI agent?
- OCR converts an image into text but does not know which text is the invoice number or the start date. The agent uses a language model to map the text to named fields, check the values against rules and decide what needs review. Most production systems use both steps together.
- Does this work for invoices as well?
- The same pattern applies, but invoices have their own rules for matching, approval and posting to accounts. Our guide on AI invoice processing covers those steps. Start with the general pattern here, then add the accounting checks once the extraction is reliable.