Jay Rathod

← Selected work

Applied AI · Document processing

Purchase Invoice Extraction

Scanned purchase invoices in, validated Excel reports out. Built alone, deployed for a private firm.

Status
Deployed, in client use
Where
Innovizia Technologies
My role
Sole engineer: design, build, deployment
~5 min
for a batch of 10 invoices
50–100 min
estimated manual entry for the same batch
50+
invoices processed in the client's first month

Overview

A private firm was keying scanned purchase invoices into spreadsheets by hand. The invoices came in many layouts, and each client wanted its own spreadsheet format. I built and deployed a platform that turns a batch of scans into a structured Excel report and flags anything it isn't sure about.

Pipeline
  1. 01 · Upload Batch of up to 10 Scanned purchase invoices
  2. 02 · OCR Qwen3-VL 8B Vision model via OpenRouter reads the scan
  3. 03 · Structure GPT-4.1 Text to fields, using configurable extraction rules
  4. 04 · Validate Totals · GST · discounts CGST, SGST and IGST checked against totals
  5. 05 · Review Human in the loop Mismatched or unreadable records are flagged
  6. 06 · Output Excel report Mapped to the client's spreadsheet format

What I did

  • Designed the two-stage pipeline and chose the models after testing alternatives.
  • Built configurable extraction rules and output mapping for varying layouts and client formats.
  • Wrote the validation layer for invoice totals, GST components and discounts.
  • Added reliability work: retries with exponential backoff, failed-invoice logging, low-balance email alerts.
  • Deployed and run it with PM2.

Engineering decisions

  1. Two models, not one

    OCR and structuring are separate stages. After testing alternatives, the split won: it shows exactly which stage an error came from, each stage can be tuned on its own, and accuracy was higher.

  2. GPT-4.1 for structuring

    Chosen for its long context window and reliable structured output. A full invoice's text fits in one call and comes back as clean fields.

  3. Flag it, don't guess

    If totals or tax components don't reconcile, or a field is unreadable, the record goes to human review. A wrong number in an accounting sheet costs more than a manual check.

  4. Expect the API to fail

    Rate limits and malformed LLM output are retried with exponential backoff. Failed invoices are logged, and an email goes out before the API balance runs dry.

Outcome

In regular use by the client. A batch of 10 invoices takes about 5 minutes, against an estimated 50–100 minutes of manual entry, and 50+ invoices went through in the first month.

Stack

  • Python
  • Qwen3-VL 8B
  • OpenRouter
  • GPT-4.1
  • Excel
  • PM2