What You’ll Build
In about two hours, you will have an invoice processing pipeline that accepts invoices in any format, whether PDF, scanned image, or email attachment, extracts vendor details, line items, totals, and payment terms, matches them against purchase orders, flags discrepancies, and routes them for approval. Processing 500 invoices takes under 20 minutes on a single dedicated GPU server with all financial data staying on-premises.
Accounts payable teams manually key invoice data into ERP systems, a process that costs $12-15 per invoice in labour and error correction. Duplicate payments, missed early-payment discounts, and data entry errors add up to 1-2% of total payables. GPU-accelerated AI processing on open-source models eliminates manual entry while catching anomalies that human processing misses at volume.
Architecture Overview
The pipeline has four stages: document intake and OCR, intelligent data extraction, validation and matching, and approval routing. PaddleOCR handles text recognition from scanned and photographed invoices with layout-aware extraction preserving table structures. An LLM through vLLM interprets the OCR output to extract structured fields, handling the varied formats across different vendors. LangChain orchestrates the multi-step pipeline with document AI processing at the front.
The validation stage cross-references extracted data against purchase orders, contract rates, and vendor master data stored in your ERP. The LLM identifies discrepancies that rule-based systems miss, such as different item descriptions for the same product, split invoices for a single PO, or payment terms that differ from the contract. Flagged invoices route to the appropriate approver based on amount thresholds and department.
GPU Requirements
| Invoice Volume | Recommended GPU | VRAM | Processing Speed |
|---|---|---|---|
| Up to 100/day | RTX 5090 | 24 GB | ~25 invoices/min |
| 100 – 1,000/day | RTX 6000 Pro | 40 GB | ~60 invoices/min |
| 1,000+/day | RTX 6000 Pro 96 GB | 80 GB | ~120 invoices/min |
OCR and LLM extraction run sequentially per invoice but batch efficiently across multiple invoices. An 8B model handles structured extraction well for standard invoice formats. Complex multi-page invoices and unusual layouts benefit from a larger model. Check our self-hosted LLM guide for model recommendations.
Step-by-Step Build
Deploy PaddleOCR and vLLM on your GPU server. Connect the document intake to your email system or shared drive where invoices arrive. Build the extraction pipeline that processes each invoice through OCR then LLM interpretation.
# Invoice extraction prompt
EXTRACT_PROMPT = """Extract structured data from this invoice.
OCR text with layout:
{ocr_output}
Return JSON:
{vendor: {name, address, tax_id, bank_details},
invoice: {number, date, due_date, currency, payment_terms},
line_items: [{description, quantity, unit_price, tax_rate, total}],
subtotal, tax_total, grand_total,
po_reference: "if present, else null"}
Match amounts: line items should sum to subtotal.
Flag any arithmetic discrepancies."""
# PO matching prompt
MATCH_PROMPT = """Match this invoice to purchase orders.
Invoice: {extracted_invoice}
Candidate POs: {candidate_pos}
Return: {matched_po: "PO number or null",
match_confidence: 0.0-1.0,
discrepancies: [{field, invoice_value, po_value, severity}]}"""
The approval routing module applies your business rules: invoices matching a PO within tolerance auto-approve, discrepancies route to procurement, and invoices without PO references route to the department head. Build a review dashboard showing pending, approved, and flagged invoices. See vLLM production setup for batch processing configuration and chatbot patterns for adding a conversational query interface.
Performance and Accuracy
On an RTX 6000 Pro, the full pipeline from OCR to validated output processes an invoice in 1.5 seconds average. Field extraction accuracy exceeds 96% for digitally generated PDFs and 91% for scanned documents. PO matching accuracy reaches 94% when invoice descriptions use similar terminology to purchase order line items. The system catches 88% of pricing discrepancies and 95% of duplicate invoice submissions.
For month-end processing surges, batch mode queues thousands of invoices and processes them overnight. The system maintains an audit trail logging every extraction decision and match for compliance review. Integration with ERP systems pushes approved invoices directly into the accounts payable ledger.
Deploy Your Invoice Processor
Automated invoice processing saves $10+ per invoice in labour costs while eliminating duplicate payments and data entry errors. Keep all financial documents and vendor data on your own infrastructure for audit compliance. Launch on GigaGPU dedicated GPU hosting and transform your AP workflow. Explore more automation patterns in our use case library.