Doc → Insight

Data & Processes • Work sample

Doc → Insight |full

Live: extract.bastian-brand.com

What it is

Messy invoices go in — as PDF, image or text — and structured data plus anomaly flags come out. The split is the point: an LLM does the reading (turning a dozen different layouts into clean fields), and deterministic rules do the checking (totals that don’t add up, duplicate invoice numbers across a batch, missing VAT id or date, outlier amounts, dates in the future). That “AI extracts, rules verify” pattern is what a finance team actually wants — automation with guardrails, not a black box you have to trust blindly.

Sample invoices are fictional; “upload or paste your own” runs live.

How I built it

For PDFs and images, text is recovered with Mistral OCR — chosen deliberately: my own PDF Parser Shootout found it the price-performance sweet spot for standard documents (fast, cheap, EU-hosted). An LLM then extracts a strict JSON schema (vendor, number, date, line items, subtotal, VAT, total), and a set of plain Python rules runs the checks across the whole batch. The extraction retries on the occasional empty response so a good result is never lost to a model hiccup; the batch is cached and custom uploads are rate-limited.

Highlights

  • Three inputs — PDF, image, or text — one pipeline
  • OCR choice backed by my own benchmark, not a guess
  • Deterministic anomaly rules on top of the LLM: auditable, not magic

Stack

Python · Streamlit · Mistral OCR · OpenRouter (LLM extraction) · pandas