DEV Community

Cover image for Document AI for invoices: schema-first extraction that auditors can trust
PRANJUL RATHOUR
PRANJUL RATHOUR

Posted on Originally published at pranjulrathour.scult.in

Document AI for invoices: schema-first extraction that auditors can trust

DocuLens AI extracts, compares and checks compliance on invoices and contracts, and every one of those verbs comes with a constraint: the output must be something an auditor can defend. "The AI said so" is not a defence. Schema-first extraction with deterministic scoring is.

Start from the schema, not the prompt

Define the fields you need — vendor, invoice number, dates, line items, totals, tax — with types and rules. The extraction prompt asks for exactly that structure, the response is parsed against it, and anything that fails validation is flagged rather than guessed. The schema is the contract between the model and the rest of the system.

Validate with arithmetic, not vibes

  • Line items must sum to the subtotal; subtotal plus tax must equal the total.
  • Dates must parse and be in a plausible order — issue before due.
  • Identifiers must match the format the vendor actually uses.
  • Any field that fails gets a confidence of zero and a visible flag, whatever the model claimed.

Deterministic scoring

Compliance checks — does this contract clause exist, does this invoice match the purchase order — are scored by rules applied to extracted fields, not by asking the model for a verdict. The same document produces the same score every time, which is the property auditors care about most. I made this argument at length in deterministic document extraction.

Compare against the source

Show each extracted value beside the region of the document it came from. Reviewers verify in seconds, corrections become training signal, and trust builds because the system never asks to be believed. This is the document equivalent of citations in RAG answers.

Architecture notes

DocuLens runs as a single Next.js application with no database and no separate backend — intentionally minimal infrastructure with enterprise-grade code. For a document tool handling sensitive files, fewer moving parts is a security feature. A fast LLM provider does the reading; rules do the judging.

About Pranjul Rathour

Pranjul Rathour in a grey suit at Dr. Virendra Swarup Institute of Computer Studies (VSICS), Kanpur
At VSICS, Kanpur

Pranjul Rathour in front of an Integral Startup Foundation hackathon backdrop
At an Integral Startup Foundation hackathon

Pranjul Rathour in a checked shirt inside a packed college auditorium
In a packed college auditorium

Pranjul Rathour in a suit and tie with a lanyard at a formal campus event
At a formal campus event

Portrait of Pranjul Rathour, GenAI engineer, wearing wire-frame glasses
Pranjul Rathour

Pranjul Rathour is a GenAI engineer from Kanpur, India, and CTO at SCULT INDIA, currently shipping production RAG,
fine-tuning and agentic AI systems, mentoring 200+ students through TechVerse Enclave, and judging and speaking at
student hackathons across India. Updated 2026-09-06.

Reach out if you want to talk GenAI, book a campus session, or invite him to judge:


Pranjul Rathour · GenAI engineer, 3x hackathon winner, campus mentor. Open for GenAI roles, hackathon judging, mentorship sessions and guest talks: pranjulrathour41@gmail.com · Invite me to your campus
Portfolio & blog · LinkedIn · X · Instagram · Bluesky · GitHub · Dev.to

Top comments (0)