How to review extracted data: Misread vs. implausible values Nutrient published a walkthrough showing how its Data Extraction API and AI Gateway's document decision model can flag bad invoice data by combining per-field citation confidence with yes/no plausibility checks on each line item. The example uses a six-line sample supplier invoice with a simulated coffee stain over line 2's quantity and a legible but odd line 5 order of 40 desk chairs, asking the model questions such as whether a quantity makes sense for an item and treating answers near 0.5 as worth a human review. The approach separates misread values, caught by citations showing where a value was found and how well the page backs it up, from implausible values that OCR copies faithfully. How to validate extracted data with AI: An invoice walkthrough Table of contents Structured output with per-field confidence scores through the Nutrient Data Extraction API. A worked invoice example: One stained number, one strange order, and the two checks that catch them. Extraction can get every character right and still hand you bad data. If an invoice contains a mistake, such as an extra zero a vendor typed, even the best optical character recognition OCR engine will copy it faithfully. And when a coffee stain lands on a quantity, the value alone can’t tell you whether it was read right. Those are different problems, so they need different checks. For the first, use the citations that Nutrient Data Extraction API https://www.nutrient.io/api/data-extraction-api/ returns with every value: where it was found on the page, and how well the page backs it up. That check has a whole post of its own catching hallucinated values in document extraction https://www.nutrient.io/blog/extraction-hallucination-detection/ , so this one keeps it short. For the second, ask Nutrient document decision https://www.nutrient.io/ai/models/ document-decision a simple question about each line, like “does this quantity make sense for this item?” Put the two together and you know which lines need a person and what that person should look at. Everything below runs on Nutrient, from one Nutrient account and plan. You’ll need two API keys: one for Data Extraction, which reads the invoice, and one for AI Gateway, which you call to run the decision model. What is extracted-data review? Extracted-data review is the step between extraction and the systems that use the data. It decides which values go straight through and which ones a person should check. The useful version asks two questions about every value. Was it read correctly from the page? And does it make sense? If both answers are yes, the value goes through. If not, it goes to a reviewer, along with the reason. How a decision request works A decision request has two parts. The state is what the model looks at: here, the line items that came back from extraction, plus a sentence of context about the order. The questions are what you want to know. Each one says what to check and what kind of answer you want back, and you can spell out what a yes and a no should mean. You can ask for three kinds of answers: - Yes/no noul — The probability that the statement is true. - Pick one choice — One option from a list you name, with a score for each option. - Scored score — A level on a rubric you define, such as low, medium, or high. You can mix all three in one request, and the model reads the state once to answer them all. For this example, yes/no questions are all you need. One thing that trips people up: A yes/no answer of 0.04 means a 4 percent chance the answer is yes, so it’s a firm no. It doesn’t mean the model is 4 percent sure of itself. Answers close to 0 or 1 are clear, while answers around 0.5 mean the model couldn’t decide, and those are worth a human glance. Extract the invoice and ask about each line The test document is a sample supplier invoice with six lines, saved as a scan-quality image with a simulated coffee stain. The stain sits on line 2, right on top of the quantity. Line 5 is perfectly legible but odd: 40 desk chairs on an office-supplies order. The checks below follow both. The extraction schema asks for four fields per line: item, quantity, unit price, and line total. Field descriptions matter here. Each item on this invoice has a smaller second line, like “Ergonomic, mesh back,” and without a clear description, the item name comes back with that line glued on. A joined value like that doesn’t match any one place on the page, so it scores low and sends a perfectly good line to review. The instructions also tell it to return what’s printed and nothing else, so it won’t “fix” a surprising quantity or guess what’s under the stain. Set includeCitations: true to get each value’s location on the page. Values come back in output.data , and their citations come back in output.metadata . Both are laid out the same way. Each citation carries a match label, which says how the value was tied to the page: id match and id match multiblock are exact, id match partial and fuzzy match are close, and not found means the page doesn’t support it. It also carries the source boxes on the page and two scores under citation.confidence . groundedness is how well that spot on the page supports the value, and ocr is how legible the text there was. Here’s the citation for the stained quantity, trimmed a little: Extraction returned 3, which is correct. The match label is exact, too, because the API found the value at a real spot on the page. But groundedness is 0.13, against 0.96 or more for the other quantities on the invoice. The API is saying it found something there, but it doesn’t trust what it read. Next, flatten the result into one record per line. Give every line an ID like line-2 and keep its citations with it. The ID is how you’ll match the decision model’s answers back to lines later, and the citations are what a reviewer opens to see the original. Then check how each number was read: quantity, unit price, and line total. Start with the match label: Anything that isn’t an exact match goes to review. Then look at groundedness, and flag the value if it’s under 0.50. On this invoice, every other number scored 0.66 or higher, and the stained one scored 0.13. One shaky number is enough to flag the whole line. Why check only the numbers? In this run, groundedness on the short item names was noisy: “Shipping,” printed perfectly clearly and scored 0.01. The numbers are where a misread costs money, and that’s where the score was reliable. Why use groundedness and not the OCR score? Plain, legible numbers on a clean line scored as low as 0.83 for OCR in this run, so a high OCR cutoff sent good lines to review. Groundedness separated the stained value from the rest much more clearly. Groundedness measures how strong the evidence is, not a probability, so tune it separately from the yes/no answers. And a missing score means no score is available, not a low score. You don’t want every line of a document sent to review because a score wasn’t returned. Now comes the decision model. Ask one yes/no question per line: Is this quantity believable for this item on this order? All six questions go in a single request, and each one gets its own answer. The model can look at the page, too. Put the page image anywhere in state as {"type": "image", "source": "data:image/png;base64,..."} . It isn’t needed for a plausibility question, but it helps with questions the text can’t answer, like whether an invoice is stamped as paid or a form is signed. The question ID is line-5 , so the answer lands on the right line. The instructions repeat line-5 , because the model never sees question IDs. For the chairs, answers "line-5" comes back as { "type": "noul", "noul": 0.36 } . The context sentence changes the answer. In an earlier run, the context described the buyer as a 40-person company, and the model rated 40 chairs as plausible 0.75 , which is fair: That’s one chair per person. Tell the model what it needs to know about the order, because it judges each line against exactly what you give it. You won’t write six questions by hand, of course. Build them from lines : Then decide which lines need a person. The reading check covers the first question and the yes/no answer covers the second. If the decision model’s answer is missing for any reason, count it as a fail, not a pass. A line goes to review if either check fails. The reading check fails when any field has a partial match, isn’t found, or has groundedness under 0.50. The plausibility check fails when the answer is under 0.50. Treat those numbers as a starting point, and test them on invoices your team has already checked. You might also want to look at anything near 0.50, where the model was on the fence. If both checks fail, keep both reasons. A quantity can look reasonable and still be misread, so a good plausibility answer should never cancel out a bad reading score. And save everything: the extraction, the decision request and response, and what the reviewer decided. When someone asks in three months why a line was held, you’ll have the answer. What happened to the two problem lines Here’s how all six lines came out. | Line | Item | Extracted quantity | Quantity groundedness | Plausible | Review reason | |---|---|---|---|---|---| | 1 | A4 copy paper, box | 12 | 0.96 | 0.70 | None | | 2 | Toner cartridge, black | 3 | 0.13 | 0.89 | Check the source reading | | 3 | Stapler, heavy duty | 2 | 0.96 | 0.90 | None | | 4 | Whiteboard markers, pack | 10 | 0.97 | 0.71 | None | | 5 | Desk chair | 40 | 0.96 | 0.36 | Check the order | | 6 | Shipping | 1 | 0.97 | 0.91 | None | Line 2 is the stain. Extraction got the three right, but with groundedness of just 0.13, so the reading check sends it to a person. The decision model rates it 0.89 for plausibility, which makes sense, because three toner cartridges is a normal order. A reviewer glances at the scan, confirms the three, and approves the line in seconds. That’s the reading check doing its job: It can’t know whether a value is right, only that the page doesn’t back it up well. Here the math agrees 3 × $89.00 is $267.00, as printed , so a line-total rule would have passed it. Had the stain turned the 3 into an 8, the math would have caught that. But a quantity with no line total next to it, or a stain on the total itself, has no such cross-check. The reading check works either way. Line 5 is the opposite. Extraction is sure of itself 0.96 , because 40 is exactly what’s printed. The decision model gives it 0.36, which isn’t a firm no but is under the 0.50 line, and it’s the lowest answer on the invoice. Nobody needs to squint at the scan for this one; someone needs to call whoever placed the order. And neither model tries to guess what the real number should be. So neither check alone would catch both problem lines. Lines 1, 3, 4, and 6 pass both and go straight through. The review reasons come from your own code. The model only returns the answers. Why not just write a rule? You could flag any quantity of more than 20 and call it done. But 40 chairs is strange for a five-person office and completely normal when a company opens a new floor. Forty boxes of paper is fine almost anywhere. To do this with rules, you’d need a limit for every item, customer, and order type, plus someone to keep them current. The decision model looks at each line in the context you give it. Rules are still the right tool for arithmetic, like checking that quantity times unit price equals the line total. Save the model for the judgment calls. Test it on your own documents One invoice shows how the approach works, but not how well it will do on your documents. Before going live, pull 100 to 200 documents your team has already checked by hand and run them through. Try a few threshold pairs and count two things: wrong values that slip through, and good lines that get sent to review anyway. Then pick the tradeoff you can live with. FAQ A misread value is one the page doesn’t clearly back up, usually because of a stain, a fold, or a bad scan. An implausible value matches the page exactly, but the page is probably wrong. They usually go to different people, which is why it helps to check them separately. A large language model LLM writes its answers out as text, and when it tells you how confident it is, that’s text too. You can’t set a reliable threshold on it. The decision model returns a number for every question, so the same threshold means the same thing on every document. Austin Nguyen explains why Nutrient built it that way in our post on why we built a decision model for documents https://www.nutrient.io/blog/decision-model-for-documents/ . Not for the decision step. Nutrient document decision runs on Nutrient’s own infrastructure, and requests aren’t sent to a third-party model provider. This invoice uses 0.50 for groundedness and 0.50 for plausibility. Treat them as a starting point, and adjust them using documents your team has already checked. Try the decision model If you want to see the model before writing any code, try your own yes/no question in the public demo on Hugging Face opens in a new tab https://huggingface.co/spaces/nutrientdocs/nutrient-document-decision-demo , with no signup needed. When you’re ready to build, both APIs are part of your Nutrient account, each with its own API key: Sign up for AI Gateway opens in a new tab https://dashboard.nutrient.io/sign up/?product=ai-gateway . If AI Gateway isn’t available for your organization yet, the AI Gateway getting started https://www.nutrient.io/guides/dws-ai-gateway/getting-started/ guide explains how to get it enabled. Citations flag what was misread, the decision model flags what looks wrong, and your reviewers only see the lines that need them. Continue reading