Learn · 7 min read

Stop Hallucinated Numbers

The short answer

Never let the model have the last word on a number. The model reads; rules and code decide. Validate every output against a schema and against the source, send uncertain reads to a person, and treat text inside documents as data, never as instructions.

Why this is harder than it looks

Even when the answer is right there on the page, models sometimes add things that aren't. An agent has it harder: it reads a scanned invoice, carries the value across three screens and types it into a field. Every hop is another chance to be wrong, and a wrong number in a ledger does not look wrong.

Eight ways a number goes wrong

FailureExampleWhat catches it
Made up An amount that is nowhere on the PDF Check the value exists in the document
Misread 8 read as B; 1,250.00 entered as 125000 Format rules plus a totals check
Wrong field Invoice number typed into the PO field Field-label anchoring, typed fields
Stale Last invoice's date on this one Clear values per item, read back
Bad math Retainage miscalculated Do math in code, never the model
Format mix-up 03/04 read as March instead of April Explicit date and unit rules
Injected Hidden text names a new bank account Treat content as data, limit permissions
Silent fail Save "worked" but a pop-up blocked it Read the record back

The pattern: model reads, code decides

Split every decision into two jobs. Here is a supplier invoice:

Steps

  1. 01

    The model reads the total, line amounts, tax, PO number and date into typed fields.

  2. 02

    Code adds the lines plus tax and compares to the total. One cent off fails.

  3. 03

    Code looks up the PO and checks price and quantity against the tolerance table.

  4. 04

    Code confirms each value really appears in the document where the model said.

  5. 05

    Anything that fails goes to a person with the reason. Nothing is retried silently.

The model is great at reading a layout it has never seen. Code is perfect at the rest and cannot be talked out of the answer.

Check meaning, not just shape

Structured output guarantees the right keys, not the right values. Add checks that look at what the values mean:

  • Types: money as fixed decimals, dates as dates
  • Ranges: no negative receipt quantities, no invoices dated next year
  • Patterns: invoice and PO numbers in the vendor's known format
  • Cross-field: lines sum to total, tax equals base times rate
  • References: vendor, item and job exist in master data
  • Source: the value is in the document

Read back every write

The agent types the right value, clicks Save, and a warning pops up behind another window. Nothing saved.

  1. After typing, read the field back and compare it character by character.

  2. After saving, look for proof: a record number, a status, a message.

  3. Before retrying, search for the record. Assuming the first try failed is how one invoice becomes two.

Gate on signals you can measure

Asking a model how sure it is gives you a number, not a measurement. Send an item to review when:

Flip the signals that are true for this item. Send an item to review when:

Green: no review signal.

Documents that try to give orders

Text hidden in a file or image can try to steer an agent, like white-on-white text naming a new bank account. Defenses help but none are perfect. The real fix is permissions: an agent that reads invoices should have no right to edit bank details at all, so an injected instruction has nothing to act on.

In LaunchAI Studio

The Dual Engine runs exact rules with no model call, and sends only messy reads to a model, one question at a time, with typed and checked outputs. Low-confidence answers go to a person. Product → Then prove it with a test set. Testing Before Production →

Step 6 · amount checklines 1,326.50 + tax 105.32 = 1,431.82 · total 1,431.82
Rule engineExact sum, no model call. 0 model calls · passes

Questions

Does temperature zero fix it?

No. It makes output repeatable, so a model can repeat the same wrong reading every time.

Will a bigger model fix it?

Not on its own, and an upgrade can change how a layout is read. Rerun your tests after every change.

Can the model do the math if it shows its work?

Keep math out of the model. Code gives the same answer every time and can be audited line by line.

No prompts. No babysitting. No Integrations.

Get a demo with our specialist team.

Get demo