Insights · Applied AI

A grounding guard: AI that can't make up a number

Business owners want an answer in plain language: how much is leaking, and where. Language models write plain language beautifully. They also state confident numbers that aren't in the data.

Merciven, our revenue-leakage product, reads the spreadsheets small businesses already keep and finds duplicate receipts, unapproved discounts and under-priced sales. The AI layer writes the explanation. A guard decides whether that explanation is allowed to reach the owner.

Compute first, then explain

The order matters. Detection runs in code: map each column to a role, run the detection methods, and produce findings. Each finding gets an ID and an exact amount.

F1  Invoice INV-1003 recorded twice           ₦51,000
F2  25% discount above the 10% policy          ₦10,200
F5  Sold below list price                      ₦16,000

Only then is the model asked to write the summary, and it is told to cite findings by ID.

The guard

Every sentence the model writes is checked before display:

  • Every figure must be computed. Each number in the sentence must match an amount in the findings (or a total of them). A naira figure that doesn't appear anywhere is rejected.
  • Every citation must exist. [F7] is fine if finding F7 exists; [F9] in a report with seven findings is rejected.
def grounded(sentence: str, findings: dict[str, int]) -> bool:
    cited = set(re.findall(r"\[(F\d+)\]", sentence))
    if not cited <= findings.keys():
        return False                      # cites something that doesn't exist
    allowed = set(findings.values()) | {sum(findings.values())}
    return all(n in allowed for n in naira_amounts(sentence))

A sentence that fails either check is rejected and never reaches the owner. The findings themselves come from code, so they never depend on the model getting it right.

Treat uploads as untrusted

A spreadsheet is user input. Cells can contain formulas, or text written to look like instructions to the model. Formulas are neutralised on upload, and cell text is passed to the model only as data, never as instructions.

Measure the parts that can be measured

The language is hard to score; the plumbing isn't. Column-role detection reaches 91.5% accuracy on a benchmark of 37 spreadsheet fixtures, the right detection method is chosen 90% of the time, and 34 HTTP integration tests cover the API end to end.

The same principle runs through our quote-to-pay system: the model drafts, typed rules and computed results decide. More on our applied AI work. Or book a free 30-minute call.