khairold
← Back to Work

Document Check

A working demo of AI document checks for digital-bank onboarding. A vision model reads a payslip or bank statement; plain, auditable rules decide; anything that doesn't add up goes to a person.

November 2026
AIVision LLMDocument AIBankingCloudflare WorkersTypeScript

Why

Most AI demos in banking stop at a slide. Onboarding and lending teams don’t need another slide. They need to see what happens when a real document hits the system: what gets read, what gets checked, and who makes the call when something is off.

So I built one you can click. It runs on three synthetic documents, and one of them is deliberately wrong.

Try it: doc-check.khairold.com

What it does

You give it an image of a payslip or a bank statement. It returns a reviewer-style result:

  1. Extracted fields. Employer or bank, period, gross, deductions, net, opening and closing balance. Personal names and account or employee numbers are masked before the result leaves the server; employer and line-item labels are shown.
  2. Rule checks. Each one is pass, warn or fail, with a one-line reason.
  3. A verdict. Either auto-pass or send to human review, with the reasons listed.

The checks:

CheckWhat it tests
Document typeIs this a payslip or a bank statement at all?
ArithmeticGross − deductions = net, or opening + credits − debits = closing
Line itemsEarnings and deduction lines add up to their totals
Date sanityPeriod not in the future, not reversed, not stale, not implausibly long
CurrencyMYR as expected
ConfidenceFields the model was unsure about
Edit signalsAnything the model describes as looking altered (can only warn)

Architecture

Browser ──► Cloudflare Worker ──► Vision model ──► Schema validation ──► Rule checks ──► Verdict
 resize      size, type, rate     reads fields     Zod; retry once,      plain code,
 ≤1600px     limits               (transcribe      else human review     deterministic
                                   only)
  • Model: Mistral Small 3.1 (vision) on Workers AI. I tried a larger model first; it read just as well but took 40–90 seconds. This one answers in under 10.
  • Runtime: one Cloudflare Worker serving the page and the API, with a Durable Object for rate limits.
  • Size: about 430 lines of TypeScript.

The choices I’d defend in a review

The model reads; code decides. The model is told to transcribe figures exactly and never correct them. Every decision comes from deterministic rules, so the same extracted fields always get the same verdict, and an auditor can follow it line by line. The system never rejects anyone: it either auto-passes or routes to a person.

The model’s opinion can warn, never reject. “This looks edited” is a model judgement. It raises a flag for a person; it can never turn a customer away on its own.

Privacy is in the code, not just the copy. In this app the image lives in memory for one request. Nothing is stored, nothing logs its content, and platform logging is off. Inference runs on Cloudflare Workers AI under Cloudflare’s terms, and rate limits are keyed by a hash of the visitor’s IP, never the IP itself.

Honest about confidence. I first showed the model’s per-field confidence scores. It scored itself 100% even when it misread a blurry copy, so I removed the numbers. Low confidence still raises a warning.

What it can’t do (yet)

  • A forged document whose numbers all add up will pass. Catching that needs issuer data, metadata and image forensics, not a language model.
  • A misread that happens to still add up would pass. In testing, the arithmetic check caught the misreads, but that’s luck, not design.
  • It runs in the cloud. For a bank, the model should run where the data is allowed to live.

How I’d evaluate it

Not measured yet; this is the harness I’d build first. A labelled set of real-world variants (phone photos, scans, crops, glare, doctored figures), field-level exact-match accuracy, and the two numbers ops cares about: bad documents that slip through as auto-pass, and good ones sent to review.

What production would add

  • A self-hosted model option for data residency and regulatory requirements
  • An audit trail for every verdict
  • A human review queue with reviewer feedback flowing back into the rules
  • The evaluation set above, run on every model or prompt change