The model reads, the code decides: AI document reading that can't put a wrong number in the books
Papers arrive as photos: invoices, weighbridge slips, payment slips. Reading them with an AI model is the easy part now. The hard part is deciding how much of what it read to believe, because a misread "8" becomes a wrong bill, and wrong bills are exactly what this backend is built to refuse. So the rule is the same as everywhere else in it: the model is allowed to read. Only code is allowed to…
The ability to read documents and accurately interpret their contents is a critical task for modern businesses. However, the challenge lies not in the reading itself, but in the subsequent decision-making process to determine the validity and accuracy of the information extracted. This is where artificial intelligence comes into play.
A novel AI-powered document reading system has been developed that excels at copying text from images such as invoices and weighbridge slips. The model meticulously copies the content verbatim into a JSON object, without attempting to add up numbers, convert units, or reformat data. All such transformations are left to the coded logic.
For example, the model may output:
```json
{
"net_weight" : "12,345 KG",
"date" : "25/11/26",
"plate" : "UP 32 XX 0000"
}
```
However, the model does not perform any calculations on this raw data. Advanced code is then used to convert the numbers to quintals (123.45), parse the date into a proper format (2026-11-25), and normalize the vehicle plate (UP32XX0000).
But the real work begins when the AI model's output is subjected to strict validation checks. Only when the calculated figures match the values on the original document, and comply with internal business rules, are they accepted. This ensures that the AI reading process is always double-checked by the coded logic, preventing any potential errors or misinterpretations from propagating through the system.
Key principles include:
1. The AI model is solely responsible for copying data
2. All calculations, conversions, and formatting are performed by the coded logic
3. Every piece of extracted information must agree with its source document
4. Checks include verifying invoice line calculations, flagging overcharged receipts, validating delivery dates, ensuring cheque amounts match, and aligning payment copies
By enforcing this separation of reading and decision-making, the system minimizes the risk of wrong numbers being entered into the books. The AI model can be easily swapped out for another without impacting the core business rules. This separation of concerns allows the focus to remain on the crucial step of human validation, ensuring that only accurate and reliable data is recorded in the accounting system.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to